Merge lp:~abreu-alexandre/webbrowser-app/fix-popup-url-redirection into lp:webbrowser-app

Proposed by Alexandre Abreu
Status: Merged
Merged at revision: 503
Proposed branch: lp:~abreu-alexandre/webbrowser-app/fix-popup-url-redirection
Merge into: lp:webbrowser-app
Diff against target: 124 lines (+56/-18)
1 file modified
src/app/webcontainer/WebViewImplOxide.qml (+56/-18)
To merge this branch: bzr merge lp:~abreu-alexandre/webbrowser-app/fix-popup-url-redirection
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Alberto Mardegan (community) Approve
Olivier Tilloy Needs Information
Review via email: mp+215328@code.launchpad.net

Commit message

Oxide (and Chromium) does not inform of non user driven navigations (or more specifically redirects that would be part of an popup/webview load (after its been granted). Quite a few sites (e.g. Youtube), create popups when clicking on links (or following a window.open()) with proper youtube.com address but w/ redirection params, e.g.:
 http://www.youtube.com/redirect?q=http%3A%2F%2Fgodzillamovie.com%2F&redir_token=b8WPI1pq9FHXeHm2bN3KVLAJSfp8MTM5NzI2NDg3NEAxMzk3MTc4NDc0

In this instance the popup & navigation is granted, but then a redirect happens inside the popup to the real target url (here http://godzillamovie.com) which is not trapped by a navigation requested and therefore not filtered. The only way to do it atm is to listen to url changes in popups & also filter there.

Description of the change

Oxide (and Chromium) does not inform of non user driven navigations (or more specifically redirects that would be part of an popup/webview load (after its been granted). Quite a few sites (e.g. Youtube), create popups when clicking on links (or following a window.open()) with proper youtube.com address but w/ redirection params, e.g.:
 http://www.youtube.com/redirect?q=http%3A%2F%2Fgodzillamovie.com%2F&redir_token=b8WPI1pq9FHXeHm2bN3KVLAJSfp8MTM5NzI2NDg3NEAxMzk3MTc4NDc0

In this instance the popup & navigation is granted, but then a redirect happens inside the popup to the real target url (here http://godzillamovie.com) which is not trapped by a navigation requested and therefore not filtered. The only way to do it atm is to listen to url changes in popups & also filter there.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:490
http://jenkins.qa.ubuntu.com/job/webbrowser-app-ci/741/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4776/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/4155/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-trusty-amd64-ci/243
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-trusty-armhf-ci/243
        deb: http://jenkins.qa.ubuntu.com/job/webbrowser-app-trusty-armhf-ci/243/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-trusty-i386-ci/243
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/4126/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4907
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4907/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4357
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4357/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/6388/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/5941

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/webbrowser-app-ci/741/rebuild

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

A question related to this work (since I didn’t have the chance to review the navigationRequested branch that landed earlier: how does createPopupWindow work on devices? Does it actually open a new window/surface? Is it being seen as a separate app by unity8?

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

> A question related to this work (since I didn’t have the chance to review the
> navigationRequested branch that landed earlier: how does createPopupWindow
> work on devices? Does it actually open a new window/surface? Is it being seen
> as a separate app by unity8?

no it does nothing on the device,

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

(nothing as in = opens in the webbrowser-app)

490. By Olivier Tilloy

Enable UA overrides for all form factors, each in a separate file.
Add an override for google calendar on desktop.
Clean up the construction of the default UA string for easier reading and maintenance.

491. By Alexandre Abreu

Make sure that we dont load unecessary libs (oxide or qtwebkit) correspnding to the webengine that we dont use. Fixes: 1306037

492. By Alexandre Abreu

Add a basic set of integration tests for the webapp container

493. By Bill Filler

Add support for file upload via content-hub

494. By PS Jenkins bot

Releasing 0.23+14.04.20140411.1-0ubuntu1

495. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

496. By Olivier Tilloy

Force the page title to be reset to an empty string when the activity view is being hidden. Fixes: 1307420

497. By PS Jenkins bot

Releasing 0.23+14.04.20140414-0ubuntu1

Revision history for this message
Alberto Mardegan (mardy) wrote :

Works as expected here.

review: Approve
498. By PS Jenkins bot

Resync trunk

499. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

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

I updated the branch w/ some extra fixes

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

FAILED: Continuous integration, rev:492
http://jenkins.qa.ubuntu.com/job/webbrowser-app-ci/763/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4914
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/4192/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-trusty-amd64-ci/265
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-trusty-armhf-ci/265
        deb: http://jenkins.qa.ubuntu.com/job/webbrowser-app-trusty-armhf-ci/265/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-trusty-i386-ci/265
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/4244
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/5063
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/5063/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4495
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4495/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/6423/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/6143

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/webbrowser-app-ci/763/rebuild

review: Needs Fixing (continuous-integration)
500. By Olivier Tilloy

Handle new view requests in the browser. Fixes: 1307735

501. By PS Jenkins bot

Releasing 0.23+14.04.20140416-0ubuntu1

Revision history for this message
Alberto Mardegan (mardy) wrote :

I re-tried the branch after the latest changes, and it still works fine :-)

502. By Alexandre Abreu

merge trunk

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/webcontainer/WebViewImplOxide.qml'
2--- src/app/webcontainer/WebViewImplOxide.qml 2014-04-15 09:20:01 +0000
3+++ src/app/webcontainer/WebViewImplOxide.qml 2014-04-18 15:46:54 +0000
4@@ -47,6 +47,10 @@
5 }
6 }
7
8+ function shouldOpenPopupsInDefaultBrowser() {
9+ return formFactor !== "desktop";
10+ }
11+
12 function isRunningAsANamedWebapp() {
13 return webview.webappName && typeof(webview.webappName) === 'string' && webview.webappName.length != 0
14 }
15@@ -55,6 +59,11 @@
16 return webappUrlPatterns && webappUrlPatterns.length !== 0
17 }
18
19+ function isNewForegroundWebViewDisposition(disposition) {
20+ return disposition === NavigationRequest.DispositionNewPopup ||
21+ disposition === NavigationRequest.DispositionNewForegroundTab;
22+ }
23+
24 function shouldAllowNavigationTo(url) {
25 // The list of url patterns defined by the webapp takes precedence over command line
26 if (isRunningAsANamedWebapp()) {
27@@ -80,6 +89,27 @@
28 }
29
30 function navigationRequestedDelegate(request) {
31+ var newForegroundPageRequest = isNewForegroundWebViewDisposition(request.disposition)
32+ var url = request.url.toString()
33+
34+ // Covers some edge cases corresponding to the default window.open() behavior.
35+ // When it is being called, the targetted URL will not load right away but
36+ // will first round trip to an "about:blank".
37+ // See https://developer.mozilla.org/en-US/docs/Web/API/Window.open
38+ if (newForegroundPageRequest && url == 'about:blank') {
39+ console.log('Accepting a new window request to navigate to "about:blank"')
40+ request.action = NavigationRequest.ActionAccept
41+ return;
42+ }
43+
44+ if (newForegroundPageRequest && shouldOpenPopupsInDefaultBrowser()) {
45+ console.debug('Opening: popup window ' + url + ' in the browser window.')
46+
47+ request.action = NavigationRequest.ActionReject
48+ Qt.openUrlExternally(url);
49+ return;
50+ }
51+
52 // Pass-through if we are not running as a named webapp (--webapp='Gmail')
53 // or if we dont have a list of url patterns specified to filter the
54 // browsing actions
55@@ -88,27 +118,10 @@
56 return
57 }
58
59- var url = request.url.toString()
60-
61- // Covers some edge cases corresponding to current Oxide potential issues (to be
62- // confirmed) that for e.g GooglePlus when a window.open() happens (or equivalent)
63- // the url that we are given (for the corresponding window.open() is 'about:blank')
64- if (url == 'about:blank') {
65- console.log('Ignoring the request to navigate to "about:blank"')
66- request.action = NavigationRequest.ActionReject
67- return;
68- }
69-
70 request.action = NavigationRequest.ActionReject
71 if (webview.shouldAllowNavigationTo(url))
72 request.action = NavigationRequest.ActionAccept
73
74- if ( ! webview.isRunningAsANamedWebapp() && request.disposition === NavigationRequest.DispositionNewPopup) {
75- console.debug('Opening: popup window ' + url + ' in the browser window.')
76- Qt.openUrlExternally(url);
77- return;
78- }
79-
80 if (request.action === NavigationRequest.ActionReject) {
81 console.debug('Opening: ' + url + ' in the browser window.')
82 Qt.openUrlExternally(url)
83@@ -132,8 +145,9 @@
84 var url = request.url.toString()
85
86 // If we are to browse in the popup to a place where we are not allows
87- if (request.disposition !== NavigationRequest.DispositionNewPopup &&
88+ if ( ! isNewForegroundWebViewDisposition(request.disposition) &&
89 ! webview.shouldAllowNavigationTo(url)) {
90+ request.action = NavigationRequest.ActionReject
91 Qt.openUrlExternally(url);
92 popup.close()
93 return;
94@@ -144,6 +158,30 @@
95 }
96
97 onNewViewRequested: webview.createPopupWindow(request)
98+
99+ // Oxide (and Chromium) does not inform of non user
100+ // driven navigations (or more specifically redirects that
101+ // would be part of an popup/webview load (after its been
102+ // granted). Quite a few sites (e.g. Youtube),
103+ // create popups when clicking on links (or following a window.open())
104+ // with proper youtube.com address but w/ redirection
105+ // params, e.g.:
106+ // http://www.youtube.com/redirect?q=http%3A%2F%2Fgodzillamovie.com%2F&redir_token=b8WPI1pq9FHXeHm2bN3KVLAJSfp8MTM5NzI2NDg3NEAxMzk3MTc4NDc0
107+ // In this instance the popup & navigation is granted, but then
108+ // a redirect happens inside the popup to the real target url (here http://godzillamovie.com)
109+ // which is not trapped by a navigation requested and therefore not filtered.
110+ // The only way to do it atm is to listen to url changed in popups & also
111+ // filter there.
112+ onUrlChanged: {
113+ var _url = url.toString();
114+ if (_url.trim().length === 0)
115+ return;
116+
117+ if (_url != 'about:blank' && ! webview.shouldAllowNavigationTo(_url)) {
118+ Qt.openUrlExternally(_url);
119+ popup.close()
120+ }
121+ }
122 }
123 Component.onCompleted: popup.show()
124 }

Subscribers

People subscribed via source and target branches

to status/vote changes: