Merge lp:~abreu-alexandre/webbrowser-app/devtools-support into lp:webbrowser-app

Proposed by Alexandre Abreu
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
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Olivier Tilloy Approve
Review via email: mp+225561@code.launchpad.net

Commit message

Add devtools support & ubuntu webview remote debugging

Description of the change

Add devtools support & ubuntu webview remote debugging

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

142 + out << " --inspector[=PORT] run a remote inspector on a specified port or" << REMOTE_INSPECTOR_PORT << "as the default port" << endl;

155 + out << " --inspector[=PORT] run a remote inspector on a specified port or" << REMOTE_INSPECTOR_PORT << "as the default 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

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

Please revert the no-op change to src/Ubuntu/Web/UbuntuWebView02.qml.

Revision history for this message
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 'webviewDevtoolsDebugPort' in src/app/browserapplication.cpp, instead of setting the env var there and reading it again in the plugin (disclaimer: not tested, but I think it ought to work). What do you think?

Revision history for this message
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.

Revision history for this message
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

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

When doing this I basically had 2 use cases in mind:

- the webbrowser-app/webapp-container being launched in a debug mode,

- 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

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

> 142 + out << " --inspector[=PORT] run a remote inspector on a
> specified port or" << REMOTE_INSPECTOR_PORT << "as the default port" << endl;
>
> 155 + out << " --inspector[=PORT] run a remote
> inspector on a specified port or" << REMOTE_INSPECTOR_PORT << "as the default
> 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/webbrowser/webbrowser-app.cpp.

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

> When doing this I basically had 2 use cases in mind:
>
> - the webbrowser-app/webapp-container being launched in a debug mode,
>
> - 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

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

> > When doing this I basically had 2 use cases in mind:
> >
> > - the webbrowser-app/webapp-container being launched in a debug mode,
> >
> > - 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

Revision history for this message
Olivier Tilloy (osomon) wrote :

Looks good and works well now. Thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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;

Subscribers

People subscribed via source and target branches

to status/vote changes: