Merge lp:~abreu-alexandre/webbrowser-app/devtools-support into lp:webbrowser-app
- devtools-support
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Olivier Tilloy |
Approved revision: | 604 |
Merged at revision: | 660 |
Proposed branch: | lp:~abreu-alexandre/webbrowser-app/devtools-support |
Merge into: | lp:webbrowser-app |
Diff against target: |
151 lines (+48/-19) 6 files modified
src/Ubuntu/Web/UbuntuWebContext.qml (+3/-0) src/Ubuntu/Web/plugin.cpp (+20/-0) src/app/browserapplication.cpp (+22/-17) src/app/browserapplication.h (+1/-0) src/app/webbrowser/webbrowser-app.cpp (+1/-1) src/app/webcontainer/webapp-container.cpp (+1/-1) |
To merge this branch: | bzr merge lp:~abreu-alexandre/webbrowser-app/devtools-support |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Olivier Tilloy | Approve | ||
Review via email:
|
Commit message
Add devtools support & ubuntu webview remote debugging
Description of the change
Add devtools support & ubuntu webview remote debugging
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Olivier Tilloy (osomon) wrote : | # |
142 + out << " --inspector[=PORT] run a remote inspector on a specified port or" << REMOTE_
155 + out << " --inspector[=PORT] run a remote inspector on a specified port or" << REMOTE_
You’re missing whitespaces after "or" and before "as". This is how it looks when invoking the app with --help:
run a remote inspector on a specified port or9221as the default port
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Olivier Tilloy (osomon) wrote : | # |
Please revert the no-op change to src/Ubuntu/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Olivier Tilloy (osomon) wrote : | # |
The rest of the changeset looks ok but I’m wondering whether using an environment variable is the best approach. With QtWebKit we didn’t really have a choice as there was no QML API to expose devtools, the only trigger we could use was the env var.
Here, we could simply set the value of the global context property 'webviewDevtool
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
David Barth (dbarth) wrote : | # |
The env. variables may still just be simpler if the port option needs to be transported to child processes, like the oxide renderers. Otherwise you have to add tons of command line options to multiple progames, where a variable is just the right unix way to do it.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Olivier Tilloy (osomon) wrote : | # |
But the env var isn’t used by oxide at all, it’s just a way to communicate between the app and the Ubuntu.Web plugin, which I think could be achieved in a simpler way.
- 602. By Alexandre Abreu
-
nits
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexandre Abreu (abreu-alexandre) wrote : | # |
When doing this I basically had 2 use cases in mind:
- the webbrowser-
- an application (third party) using the ubuntu webview and one wanting to "black box" debug it w/o having to touch it (either because one cannot or should not). I was thinking mostly QA needs to AP test UI componenets that use the UbuntuWebView w/o having to touch it. They would need a way to turn on the devtools w/o having access to the app itself, before being able to drive it w/ selenium etc.
In that context, some sort of an env var seemed ok to me,
The other points have been addressed
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:602
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Olivier Tilloy (osomon) wrote : | # |
> 142 + out << " --inspector[=PORT] run a remote inspector on a
> specified port or" << REMOTE_
>
> 155 + out << " --inspector[=PORT] run a remote
> inspector on a specified port or" << REMOTE_
> port" << endl;
>
> You’re missing whitespaces after "or" and before "as". This is how it looks
> when invoking the app with --help:
>
> run a remote inspector on a specified port or9221as the default port
This still needs to be fixed in src/app/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Olivier Tilloy (osomon) wrote : | # |
> When doing this I basically had 2 use cases in mind:
>
> - the webbrowser-
>
> - an application (third party) using the ubuntu webview and one wanting to
> "black box" debug it w/o having to touch it (either because one cannot or
> should not). I was thinking mostly QA needs to AP test UI componenets that use
> the UbuntuWebView w/o having to touch it. They would need a way to turn on the
> devtools w/o having access to the app itself, before being able to drive it w/
> selenium etc.
>
> In that context, some sort of an env var seemed ok to me,
I guess that makes sense. One thing I just noticed is that oxide allows us to specify only a numerical port, no host. I guess it means we cannot connect to a webview running on a different device? With QtWebKit, we were able to connect to a webview running on a phone from a separate desktop machine.
- 603. By Alexandre Abreu
-
nits
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:603
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexandre Abreu (abreu-alexandre) wrote : | # |
> > When doing this I basically had 2 use cases in mind:
> >
> > - the webbrowser-
> >
> > - an application (third party) using the ubuntu webview and one wanting to
> > "black box" debug it w/o having to touch it (either because one cannot or
> > should not). I was thinking mostly QA needs to AP test UI componenets that
> use
> > the UbuntuWebView w/o having to touch it. They would need a way to turn on
> the
> > devtools w/o having access to the app itself, before being able to drive it
> w/
> > selenium etc.
> >
> > In that context, some sort of an env var seemed ok to me,
>
> I guess that makes sense. One thing I just noticed is that oxide allows us to
> specify only a numerical port, no host. I guess it means we cannot connect to
> a webview running on a different device? With QtWebKit, we were able to
> connect to a webview running on a phone from a separate desktop machine.
Yes, this is a shortcoming in oxide that I'll address w/ a MR there,
- 604. By Alexandre Abreu
-
fix port parsing
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Olivier Tilloy (osomon) wrote : | # |
Looks good and works well now. Thanks!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:604
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'src/Ubuntu/Web/UbuntuWebContext.qml' |
2 | --- src/Ubuntu/Web/UbuntuWebContext.qml 2014-07-08 08:43:57 +0000 |
3 | +++ src/Ubuntu/Web/UbuntuWebContext.qml 2014-08-11 14:45:28 +0000 |
4 | @@ -79,4 +79,7 @@ |
5 | ] |
6 | |
7 | property QtObject __ua: UserAgent02 {} |
8 | + |
9 | + devtoolsEnabled: webviewDevtoolsDebugPort !== -1 |
10 | + devtoolsPort: webviewDevtoolsDebugPort |
11 | } |
12 | |
13 | === modified file 'src/Ubuntu/Web/plugin.cpp' |
14 | --- src/Ubuntu/Web/plugin.cpp 2014-07-04 11:38:27 +0000 |
15 | +++ src/Ubuntu/Web/plugin.cpp 2014-08-11 14:45:28 +0000 |
16 | @@ -64,6 +64,24 @@ |
17 | return DESKTOP; |
18 | } |
19 | |
20 | +static int getDevtoolsPort() |
21 | +{ |
22 | + const int DEVTOOLS_INVALID_PORT = -1; |
23 | + |
24 | + int port = DEVTOOLS_INVALID_PORT; |
25 | + const char* DEVTOOLS_PORT_ENV_VAR = "UBUNTU_WEBVIEW_DEVTOOLS_PORT"; |
26 | + |
27 | + if (qEnvironmentVariableIsSet(DEVTOOLS_PORT_ENV_VAR)) { |
28 | + QByteArray environmentVarValue = qgetenv(DEVTOOLS_PORT_ENV_VAR); |
29 | + bool ok = false; |
30 | + int value = environmentVarValue.toInt(&ok); |
31 | + if (ok) { |
32 | + port = value; |
33 | + } |
34 | + } |
35 | + return port > 0 ? port : DEVTOOLS_INVALID_PORT; |
36 | +} |
37 | + |
38 | void UbuntuBrowserPlugin::initializeEngine(QQmlEngine* engine, const char* uri) |
39 | { |
40 | Q_UNUSED(uri); |
41 | @@ -82,6 +100,8 @@ |
42 | } |
43 | |
44 | context->setContextProperty("formFactor", getFormFactor()); |
45 | + |
46 | + context->setContextProperty("webviewDevtoolsDebugPort", getDevtoolsPort()); |
47 | } |
48 | |
49 | void UbuntuBrowserPlugin::registerTypes(const char* uri) |
50 | |
51 | === modified file 'src/app/browserapplication.cpp' |
52 | --- src/app/browserapplication.cpp 2014-05-22 15:27:38 +0000 |
53 | +++ src/app/browserapplication.cpp 2014-08-11 14:45:28 +0000 |
54 | @@ -58,6 +58,23 @@ |
55 | delete m_engine; |
56 | } |
57 | |
58 | +QString BrowserApplication::inspectorPort() const |
59 | +{ |
60 | + QString port; |
61 | + Q_FOREACH(const QString& argument, m_arguments) { |
62 | + if (argument == "--inspector") { |
63 | + // default port |
64 | + port = QString::number(REMOTE_INSPECTOR_PORT); |
65 | + break; |
66 | + } |
67 | + if (argument.startsWith("--inspector=")) { |
68 | + port = argument.split("--inspector=")[1]; |
69 | + break; |
70 | + } |
71 | + } |
72 | + return port; |
73 | +} |
74 | + |
75 | QString BrowserApplication::appId() const |
76 | { |
77 | Q_FOREACH(const QString& argument, m_arguments) { |
78 | @@ -99,22 +116,10 @@ |
79 | QOpenGLContextPrivate::setGlobalShareContext(glcontext); |
80 | #endif |
81 | |
82 | - bool inspector = m_arguments.contains("--inspector"); |
83 | - if (inspector) { |
84 | - QString host; |
85 | - Q_FOREACH(QHostAddress address, QNetworkInterface::allAddresses()) { |
86 | - if (!address.isLoopback() && (address.protocol() == QAbstractSocket::IPv4Protocol)) { |
87 | - host = address.toString(); |
88 | - break; |
89 | - } |
90 | - } |
91 | - QString server; |
92 | - if (host.isEmpty()) { |
93 | - server = QString::number(REMOTE_INSPECTOR_PORT); |
94 | - } else { |
95 | - server = QString("%1:%2").arg(host, QString::number(REMOTE_INSPECTOR_PORT)); |
96 | - } |
97 | - qputenv("QTWEBKIT_INSPECTOR_SERVER", server.toUtf8()); |
98 | + QString devtoolsPort = inspectorPort(); |
99 | + bool inspectorEnabled = !devtoolsPort.isEmpty(); |
100 | + if (inspectorEnabled) { |
101 | + qputenv("UBUNTU_WEBVIEW_DEVTOOLS_PORT", devtoolsPort.toUtf8()); |
102 | } |
103 | |
104 | m_engine = new QQmlEngine; |
105 | @@ -139,7 +144,7 @@ |
106 | m_window = qobject_cast<QQuickWindow*>(browser); |
107 | m_webbrowserWindowProxy->setWindow(m_window); |
108 | |
109 | - browser->setProperty("developerExtrasEnabled", inspector); |
110 | + browser->setProperty("developerExtrasEnabled", inspectorEnabled); |
111 | |
112 | return true; |
113 | } |
114 | |
115 | === modified file 'src/app/browserapplication.h' |
116 | --- src/app/browserapplication.h 2014-05-22 15:27:38 +0000 |
117 | +++ src/app/browserapplication.h 2014-08-11 14:45:28 +0000 |
118 | @@ -58,6 +58,7 @@ |
119 | |
120 | private: |
121 | QString appId() const; |
122 | + QString inspectorPort() const; |
123 | |
124 | WebBrowserWindow *m_webbrowserWindowProxy; |
125 | }; |
126 | |
127 | === modified file 'src/app/webbrowser/webbrowser-app.cpp' |
128 | --- src/app/webbrowser/webbrowser-app.cpp 2014-07-10 10:09:57 +0000 |
129 | +++ src/app/webbrowser/webbrowser-app.cpp 2014-08-11 14:45:28 +0000 |
130 | @@ -113,7 +113,7 @@ |
131 | out << " -h, --help display this help message and exit" << endl; |
132 | out << " --fullscreen display full screen" << endl; |
133 | out << " --maximized opens the application maximized" << endl; |
134 | - out << " --inspector run a remote inspector on port " << REMOTE_INSPECTOR_PORT << endl; |
135 | + out << " --inspector[=PORT] run a remote inspector on a specified port or " << REMOTE_INSPECTOR_PORT << " as the default port" << endl; |
136 | out << " --app-id=APP_ID run the application with a specific APP_ID" << endl; |
137 | } |
138 | |
139 | |
140 | === modified file 'src/app/webcontainer/webapp-container.cpp' |
141 | --- src/app/webcontainer/webapp-container.cpp 2014-07-31 21:31:29 +0000 |
142 | +++ src/app/webcontainer/webapp-container.cpp 2014-08-11 14:45:28 +0000 |
143 | @@ -188,7 +188,7 @@ |
144 | out << " --fullscreen display full screen" << endl; |
145 | out << " --local-webapp-manifest configure the webapp assuming that it has a local manifest.json file" << endl; |
146 | out << " --maximized opens the application maximized" << endl; |
147 | - out << " --inspector run a remote inspector on port " << REMOTE_INSPECTOR_PORT << endl; |
148 | + out << " --inspector[=PORT] run a remote inspector on a specified port or " << REMOTE_INSPECTOR_PORT << " as the default port" << endl; |
149 | out << " --app-id=APP_ID run the application with a specific APP_ID" << endl; |
150 | out << " --homepage=URL override any URL passed as an argument" << endl; |
151 | out << " --webapp=name try to match the webapp by name with an installed integration script" << endl; |
FAILED: Continuous integration, rev:601 jenkins. qa.ubuntu. com/job/ webbrowser- app-ci/ 917/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- utopic- touch/1548/ console jenkins. qa.ubuntu. com/job/ generic- mediumtests- utopic/ 1338/console jenkins. qa.ubuntu. com/job/ webbrowser- app-utopic- amd64-ci/ 116/console jenkins. qa.ubuntu. com/job/ webbrowser- app-utopic- armhf-ci/ 116/console jenkins. qa.ubuntu. com/job/ webbrowser- app-utopic- i386-ci/ 116/console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- armhf/2535/ console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- amd64/1502/ console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/webbrowser- app-ci/ 917/rebuild
http://