Merge lp:~abreu-alexandre/webbrowser-app/container-extension into lp:webbrowser-app

Proposed by Alexandre Abreu
Status: Approved
Approved by: Alberto Mardegan
Approved revision: no longer in the source branch.
Proposed branch: lp:~abreu-alexandre/webbrowser-app/container-extension
Merge into: lp:webbrowser-app
Diff against target: 757 lines (+382/-83)
13 files modified
src/app/webcontainer/UrlFilteringUtils.js (+82/-0)
src/app/webcontainer/WebApp.qml (+1/-0)
src/app/webcontainer/WebViewImplOxide.qml (+20/-0)
src/app/webcontainer/WebappContainerWebview.qml (+85/-5)
src/app/webcontainer/main-webview-server-script.js (+33/-0)
src/app/webcontainer/url-pattern-utils.cpp (+1/-1)
src/app/webcontainer/webapp-container.cpp (+28/-0)
src/app/webcontainer/webapp-container.qml (+16/-67)
tests/autopilot/webapp_container/tests/__init__.py (+5/-5)
tests/autopilot/webapp_container/tests/fake_servers.py (+5/-0)
tests/autopilot/webapp_container/tests/test_chrome.py (+4/-4)
tests/autopilot/webapp_container/tests/test_container_extension.py (+101/-0)
tests/autopilot/webapp_container/tests/test_context_menu.py (+1/-1)
To merge this branch: bzr merge lp:~abreu-alexandre/webbrowser-app/container-extension
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Needs Fixing
Alberto Mardegan (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+278870@code.launchpad.net

Commit message

Introduce a new extension mechanism for the container that allows webapps to plugin into a discrete set of events coming from the container.

Description of the change

Introduce a new extension mechanism for the container that allows webapps to plugin into a discrete set of events coming from the container.

A user has to add a webapp-extend.qml file in the webapp, that should expose a handle() function. This function is called for specific events, at the moment, mostly around url updates (coming from things like urihandler or internally from the user).

To see an example of such an extension usage:

https://code.launchpad.net/~abreu-alexandre/webapps-core/gmail-mailto-support/+merge/278871

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

Fix local Toolbar collision with UITK 1.3 Toolbar.
Approved by: Olivier Tilloy, Zoltan Balogh

1299. By Olivier Tilloy

Work around what appears to be a regression in the UITK by specifying a non-null delay when swiping a list item to delete it in unit tests. Fixes: #1526940
Approved by: Michael Sheldon

1300. By CI Train Bot Account

Releasing 0.23+16.04.20151218-0ubuntu1

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

Please document what translateHandlerUri() and translateUri() do, because otherwise it's very difficult to understand what is happening here :-)

1301. By Michael Sheldon

Add support for handling downloads internally within the browser. Fixes: #1354391
Approved by: Olivier Tilloy

1302. By CI Train Bot Account

Releasing 0.23+16.04.20151221-0ubuntu1

1303. By Olivier Tilloy

Update translation template.

1304. By Olivier Tilloy

Recognize openoffice and MS-office file formats as documents, now that the document viewer app knows how to render them. Fixes: #1523452
Approved by: Michael Sheldon, PS Jenkins bot

1305. By Olivier Tilloy

Do not allow interacting with tabs and the chrome while the settings page is shown. Fixes: #1524353
Approved by: PS Jenkins bot, Ugo Riboni

1306. By Olivier Tilloy

Use the screen size (diagonal in millimeters) to determine which default UA string and which UA overrides to use.
An empirical threshold of 19cm is being used, it is subject to further adjustments. Fixes: #1504084
Approved by: PS Jenkins bot

1307. By Olivier Tilloy

Add keyboard shorcuts for 'next' (Ctrl+G) and 'previous' (Ctrl+Shift+G) while in find-in-page mode. Fixes: #1522152
Approved by: PS Jenkins bot, Ugo Riboni

1308. By Olivier Tilloy

Fix the tab preview sometimes covering the tab chrome, in the tabs view.
Offset tab previews by 1px to cover the semi-transparent horizontal line at the bottom of the tab chrome asset. Fixes: #1520624
Approved by: PS Jenkins bot, Ugo Riboni

1309. By Olivier Tilloy

Fix some obvious issues in PreviewManager. Fixes: #1519019
Approved by: PS Jenkins bot, Ugo Riboni

1310. By Olivier Tilloy

Fix a crash when clearing the navigation history while the new tab view is open. Fixes: #1525937
Approved by: Ugo Riboni

1311. By Olivier Tilloy

Fix deleting multiple domains from the history view.
Add unit tests for the HistoryView component. Fixes: #1527144

1312. By CI Train Bot Account

Releasing 0.23+16.04.20151222.1-0ubuntu1

1313. By CI Train Bot Account

Resync trunk.

1314. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1315. By Alexandre Abreu

Make the webapp-container click hook more flexible. Instead of being able to delete cache & resource folders as the click is being uninstalled, one can also act on them as the click is being upgraded & installed. Fixes: #1522562
Approved by: PS Jenkins bot, Alberto Mardegan

1316. By Alexandre Abreu

Handle empty url pattern in configuration file and invalid url pattern being specified. Fixes: #1522585
Approved by: PS Jenkins bot, Alberto Mardegan

1317. By Alexandre Abreu

Handle application crashes or OOM interventions & save opened overlays Fixes: #1508969
Approved by: PS Jenkins bot, Alberto Mardegan

1318. By Alexandre Abreu

Limited handling of custom context menu for the container
Approved by: Alberto Mardegan

1319. By CI Train Bot Account

Releasing 0.23+16.04.20160106.4-0ubuntu1

1320. By Alexandre Abreu

Handle theme_color page metainformation. Fixes: #1477674
Approved by: Alberto Mardegan

1321. By CI Train Bot Account

Releasing 0.23+16.04.20160108.1-0ubuntu1

1322. By CI Train Bot Account

Resync trunk.

1323. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1324. By Olivier Tilloy

Restore active focus on the webview after closing the context menu. Fixes: #1526884
Approved by: Bill Filler

1325. By Michael Sheldon

Dynamically load the thumbnailer image provider if it's available, otherwise fallback to mimetype images Fixes: #1531179
Approved by: Olivier Tilloy

1326. By Olivier Tilloy

Address a number of minor functional and code issues in the new downloads-in-browser functionality. Fixes: #1528651
Approved by: Michael Sheldon

1327. By CI Train Bot Account

Releasing 0.23+16.04.20160112.1-0ubuntu1

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

> Please document what translateHandlerUri() and translateUri() do, because
> otherwise it's very difficult to understand what is happening here :-)

I updated the branch with some documentation

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 :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alberto Mardegan (mardy) wrote :

Thanks for the explanations. I've added a few more inline comments, and here are two generic remarks:

1) You should document somewhere the list of hooks that can be intercepted by the webapp script. Some king of a readme where we document the hook names, their parameters and return values.

2) I really don't like using a Loader in order to load the script: a Loader is used to use a QQuick item, while what we really need is a JS object (also, using a Loader makes the loading of the webview even more complex). I haven't researched this in depth, and indeed it may be that QML doesn't offer much in terms of dynamically loading .js files. At a first sight, it looks like QJSEngine::evaluate() could be a good option: in webcontainer.cpp you could check if the webapp ships a .js file, load it, let the QQmlEngine (which is a subclass of QJSEngine) evaluate it and then set the returned QJSValue as a property of the main QML file we load:
http://doc.qt.io/qt-5/qjsengine.html#evaluate
I never did anything similar, but I believe that it should work.

review: Needs Fixing
1328. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1329. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1330. By Olivier Tilloy

Fix failing autopilot test.
With recent changes in the UITK, swiping a non-swipeable item to the right activates it. Fixes: #1534139

1331. By Olivier Tilloy

Automatically focus the address bar when opening a new tab in wide mode (instead of inferring a "desktop" form factor).
This is not exactly the correct fix (which would require the QInputInfo API), but is better than the current situation anyway. Fixes: #1533317

1332. By Olivier Tilloy

Show the share action if Ubuntu.Content is available, regardless of the form factor.

1333. By Olivier Tilloy

Fix undefined reference when dragging a bookmark from one folder to another one.

1334. By Olivier Tilloy

Ensure that only one instance of the app is running. Fixes: #1535199
Approved by: Alexandre Abreu

1335. By CI Train Bot Account

Releasing 0.23+16.04.20160122-0ubuntu1

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

> Thanks for the explanations. I've added a few more inline comments

see my comments inline (I updated most)

> , and here
> are two generic remarks:
>
> 1) You should document somewhere the list of hooks that can be intercepted by
> the webapp script. Some king of a readme where we document the hook names,
> their parameters and return values.

agree, done (not as a readme though)

> 2) I really don't like using a Loader in order to load the script: a Loader is
> used to use a QQuick item, while what we really need is a JS object (also,
> using a Loader makes the loading of the webview even more complex). I haven't
> researched this in depth, and indeed it may be that QML doesn't offer much in
> terms of dynamically loading .js files. At a first sight, it looks like
> QJSEngine::evaluate() could be a good option: in webcontainer.cpp you could
> check if the webapp ships a .js file, load it, let the QQmlEngine (which is a
> subclass of QJSEngine) evaluate it and then set the returned QJSValue as a
> property of the main QML file we load:
> http://doc.qt.io/qt-5/qjsengine.html#evaluate
> I never did anything similar, but I believe that it should work.

yes it would work this is what I do for URI filtering code (see comment) in scheme-filter.cpp.

But for this extension mechanism part, I wanted something simpler maybe and more
flexible than plain QJSEngine ... If one wanted to put a bit more logic in
the 'extension', and possibly have more than one file which is not possible with
QJSEngine (import does not work).

WDYT?

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

Thanks for the update. I didn't know of the QJSEngine limitation about "import" not working; I would still prefer to go through that route, and eventually reconsider it if/when it turns out we really need "import" to work (and who knows, maybe QJSEngine will have support for it by then).

However, I'm not going to block the review on this, if you disagree.

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

> Thanks for the update. I didn't know of the QJSEngine limitation about
> "import" not working; I would still prefer to go through that route, and
> eventually reconsider it if/when it turns out we really need "import" to work
> (and who knows, maybe QJSEngine will have support for it by then).
>
> However, I'm not going to block the review on this, if you disagree.

well this is a discussion :)

I thought about it and the idea behind the extension option really fits the qml land.
It is not only a pure js bit (although it is in the example), it should have the option
to talk back and forth with the webview and possibly create qml elements of its own
which is not really possible (or with some painful crafted code which would in the end
look simpler with plain qml loading),

wdyt?

would it be better if I used a synchronised Qt.createQmlObject('<with source>') instead
to remove the Loader bit?

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

> would it be better if I used a synchronised Qt.createQmlObject('<with
> source>') instead
> to remove the Loader bit?

This looks like a good compromise: it allows the extension to live in the QML word, and doesn't suggest that we want the extension to return something visible.

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

> > would it be better if I used a synchronised Qt.createQmlObject('<with
> > source>') instead
> > to remove the Loader bit?
>
> This looks like a good compromise: it allows the extension to live in the QML
> word, and doesn't suggest that we want the extension to return something
> visible.

I updated the branch

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

There's a merge conflict, but the new code looks fine, thanks!

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 :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alberto Mardegan (mardy) :
review: Approve
1336. By Olivier Tilloy

Add a UA override for desktop gmail to get rid of a misleading warning about using a deprecated version of safari. Fixes: #1452616
Approved by: Alexandre Abreu

1337. By Olivier Tilloy

Update tab visuals to higher-contrast assets. Fixes: #1534760

1338. By Olivier Tilloy

Do not connect to the loadingChanged signal, which has been deprecated for a good while. Fixes: #1538190
Approved by: Alexandre Abreu

1339. By Olivier Tilloy

In narrow mode, when a mouse is connected, turn the bottom edge hint into a clickable bottom edge bar. Fixes: #1534239
Approved by: Jamie Strandboge

1340. By Olivier Tilloy

Update focus highlight to match the upcoming UITK implementation. Fixes: #1539176

1341. By CI Train Bot Account

Releasing 0.23+16.04.20160129.1-0ubuntu1

1342. By CI Train Bot Account

Resync trunk.

1343. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1344. By Alexandre Abreu

Enhance google.com specific patterns to enable co.* & com.* patterns
 Fixes: #1517527
Approved by: PS Jenkins bot, Olivier Tilloy

1345. By Alexandre Abreu

Make sure that the overlay views closed by the user are not part of the list of recovered overlays opened after the oom closed the app. Fixes: #1535154
Approved by: Alberto Mardegan

1346. By CI Train Bot Account

Releasing 0.23+16.04.20160202-0ubuntu1

1347. By CI Train Bot Account

Resync trunk.

1348. By Olivier Tilloy

Add video-specific contextual actions. Fixes: #1539676

1349. By Olivier Tilloy

Use the new bottom edge bar to open the tabs view in autopilot tests.

1350. By Olivier Tilloy

Add keyboard navigation support to narrow views (new tab view, history view, bookmarks view, downloads view). Fixes: #1539221

1351. By Olivier Tilloy

Take a capture of the current page shortly after it has finished loading to give rendering an opportunity to complete. Fixes: #1540129

1352. By CI Train Bot Account

Releasing 0.23+16.04.20160215.1-0ubuntu1

1353. By CI Train Bot Account

Resync trunk.

1354. By Olivier Tilloy

Update translation template.

1355. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1356. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1357. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1358. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1359. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1360. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1361. By Olivier Tilloy

Remove the 'formFactor' context property, and replace all its uses by more meaningful conditions. Fixes: #1446904, #1542375

1362. By Olivier Tilloy

Work around bug #1546677 (UITK), by destroying the bookmark options popover instead of hiding it. Fixes: #1546627, #1546677

1363. By Olivier Tilloy

Work around a bug in the UITK that prevents touch scrolling to the left of the address bar by ensuring that the x coordinate of the text field is an integer. Fixes: #1546346

1364. By CI Train Bot Account

Releasing 0.23+16.04.20160223-0ubuntu1

1365. By CI Train Bot Account

Resync trunk.

1366. By Olivier Tilloy

Update translation template.

1367. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1368. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1369. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1370. By Olivier Tilloy

Refer to @{XDG_DOWNLOAD_DIR} in the browser’s apparmor profile instead of hardcoding "Downloads" in English. Fixes: #1535666
Approved by: Jamie Strandboge

1371. By Olivier Tilloy

Visual tweaks per designers’ review.

1372. By Olivier Tilloy

Store entries in the history database on load committed, not load succeeded.
This ensures that content-initiated navigations are also stored. Fixes: #1455858, #1549780
Approved by: Riccardo Padovani

1373. By CI Train Bot Account

Releasing 0.23+16.04.20160303-0ubuntu1

1374. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1375. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1376. By Alexandre Abreu

Handle context menu in overlay webviews. Fixes: #1533727
Approved by: David Barth, Alberto Mardegan, Olivier Tilloy

1377. By CI Train Bot Account

Releasing 0.23+16.04.20160307-0ubuntu1

1378. By CI Train Bot Account

Resync trunk.

1379. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1380. By Olivier Tilloy

Add a touch selection controller. Fixes: #1376268, #1551494
Approved by: Alexandre Abreu

1381. By CI Train Bot Account

Releasing 0.23+16.04.20160310-0ubuntu1

1382. By Alberto Mardegan

Activate the Webapp only when we are ready to navigate to the webapp URL
 Fixes: #1507995
Approved by: Alexandre Abreu

1383. By CI Train Bot Account

Releasing 0.23+16.04.20160311-0ubuntu1

1384. By CI Train Bot Account

Resync trunk.

1385. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1386. By Alexandre Abreu

Handle media access request from webcontainer main view and overlay views Fixes: #1554202
Approved by: Olivier Tilloy

1387. By CI Train Bot Account

Releasing 0.23+16.04.20160318-0ubuntu1

1388. By Olivier Tilloy

Tentative fix for a bug where the session state stored on disk is apparently corrupted, thus discarding the current browsing session. Fixes: #1531583

1389. By Olivier Tilloy

Make google maps work in complete mode on tablets. Fixes: #1560079

1390. By CI Train Bot Account

Releasing 0.23+16.04.20160322-0ubuntu1

1391. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1392. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1393. By Alexandre Abreu

Add --open-external-url-in-overlay option to allow externals urls (not part of patterns) are opened in overlays instead of external browser Fixes: #1548575
Approved by: David Barth, Alberto Mardegan

1394. By Alexandre Abreu

Handle live updates to theme color meta tag and reflect them in the top bar background color Fixes: #1550754
Approved by: Alberto Mardegan

1395. By Alexandre Abreu

Set address bar text color to a darker version of the theme color if one is defined in a webapp Fixes: #1548573
Approved by: Alberto Mardegan

1396. By CI Train Bot Account

Releasing 0.23+16.04.20160405-0ubuntu1

1397. By CI Train Bot Account

Resync trunk.

1398. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1399. By Olivier Tilloy

Remove workaround for bug #1526940 that was fixed in the latest release of the UITK.

1400. By Olivier Tilloy

Customize the contents of the media permission dialog to avoid truncated text. Fixes: #1554220

1401. By Olivier Tilloy

Fix broken webapp container autopilot tests. Fixes: #1557019
Approved by: Alexandre Abreu

1402. By Olivier Tilloy

Catch ESC key event one level up to ensure that it’s not incorrectly bubbled up to the outer component. Fixes: #1557016

1403. By Olivier Tilloy

Add dep8 tests and instructions to run them in qemu or on a phone.
Original work by Leo Arias and Vincent Ladeuil.

1404. By Olivier Tilloy

Rename debian packages to follow new QML module naming convention. Fixes: #1342031
Approved by: Timo Jyrinki

1405. By Olivier Tilloy

Make the autopilot tests more reliable when dragging the bottom edge. Fixes: #1560109

1406. By Olivier Tilloy

Fix issues with item selection in the downloads page:
 - do not allow selecting multiple files when only one is expected
 - do not allow entering delete mode (with a long press on an item) while in picker mode Fixes: #1534112, #1561575

1407. By Olivier Tilloy

Import QQuickShortcut from Qt 5.5 to properly handle window-level keyboard shortcuts.
We cannot bump the dependency on Qt to 5.5 as the stable overlay PPA for devices currently has Qt 5.4.1. Fixes: #1537782, #1542224, #1545802

1408. By Loïc Molinari

Made AddressBar height scalable with regards to the grid units system.
Approved by: Olivier Tilloy

1409. By Olivier Tilloy

Do not write the session to a temporary file when no target file is defined.

1410. By Olivier Tilloy

Fix a failing unit test with Qt 5.6. Fixes: #1565507

1411. By Olivier Tilloy

Fix unit tests when run under an sbuild chroot. Fixes: #1567294

1412. By Olivier Tilloy

Simplify the implementation of HistoryViewWide quite a bit,
and as a side effect fix a unit test failure when run against the staging branch of the UITK. Fixes: #1567337

1413. By CI Train Bot Account

Releasing 0.23+16.04.20160408.1-0ubuntu1

1414. By Olivier Tilloy

Update translation template.

1415. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1416. By Olivier Tilloy

Do not handle backspace as a window-level shortcut,
as it would take precedence over backspace events in HTML text fields. Fixes: #1569938

1417. By CI Train Bot Account

Releasing 0.23+16.04.20160413-0ubuntu1

1418. By CI Train Bot Account

Resync trunk.

1419. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1420. By Timo Jyrinki

Fix FTBFS on Qt 5.6 by adding a dependency on qttools5-dev-tools for qdoc Fixes: #1565502
Approved by: Olivier Tilloy

1421. By Olivier Tilloy

Add a progression symbol to list items that open new pages in settings. Fixes: #1517206

1422. By Olivier Tilloy

Add UA overrides for google hangouts to work on desktop, tablet and phone. Fixes: #1565055

1423. By Olivier Tilloy

Simplify focus handling in various places.

1424. By Olivier Tilloy

Remove duplicated list view focus rects,
and update the styling of the remaining ones to match that of the UITK. Fixes: #1570807

1425. By CI Train Bot Account

Releasing 0.23+16.04.20160415-0ubuntu1

1426. By CI Train Bot Account

Resync trunk.

1427. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1428. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1429. By Alexandre Abreu

Track SAML requests that are part of redirection chains and do not trigger a navigation requested delegate. Fixes: #1573017
Approved by: Alberto Mardegan

1430. By Alexandre Abreu

Fix invalid variable reference popupWindowController Fixes: #1572673
Approved by: Alberto Mardegan

1431. By CI Train Bot Account

Releasing 0.23+16.04.20160425.2-0ubuntu1

1432. By CI Train Bot Account

Resync trunk.

1433. By Olivier Tilloy

Autopkgtest fixes.
Approved by: Michał Sawicz

1434. By Olivier Tilloy

When sharing a link, correctly share its URL and title. Fixes: #1571361

1435. By CI Train Bot Account

Releasing 0.23+16.04.20160427-0ubuntu1

1436. By CI Train Bot Account

Resync trunk.

1437. By Olivier Tilloy

Use the UITK’s SwipeArea component for the bottom edge gesture recognition.
This requires oxide 1.14 to work well (because of bug #1459362). Fixes: #1458037, #1474533, #1491806

1438. By Olivier Tilloy

Skip geolocation autopilot tests because they are now failing with oxide 1.14.

1439. By Olivier Tilloy

Read the ubuntu version at build time, instead of hardcoding it. Fixes: #1466427

1440. By CI Train Bot Account

Releasing 0.23+16.04.20160428-0ubuntu1

1441. By CI Train Bot Account

Resync trunk.

1442. By Alexandre Abreu

Specify a parent for embedded uis being launched by webapps Fixes: #1550397
Approved by: Alberto Mardegan

1443. By Alexandre Abreu

Add facebook UA override that fixes photos not being displayed with the right size, and improves the UIs and features (add photos etc.) Fixes: #1457661, #1538056
Approved by: Alberto Mardegan

1444. By Alexandre Abreu

Tweak container context menu open in browser string Fixes: #1532937
Approved by: Olivier Tilloy

1445. By CI Train Bot Account

Releasing 0.23+16.04.20160429.1-0ubuntu1

1446. By CI Train Bot Account

Resync trunk.

1447. By Olivier Tilloy

Update translation template.

1448. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1449. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

1450. By Alexandre Abreu

Introduce a new extension mechanism for the container that allows webapps to plugin into a discrete set of events coming from the container

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1450
https://jenkins.canonical.com/system-apps/job/lp-webbrowser-app-ci/581/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/957
    UNSTABLE: https://jenkins.canonical.com/system-apps/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=default/172
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/957
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/861
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/861
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/861
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/858
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/858/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/858
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/858/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/858
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/858/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/858
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/858/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/858
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/858/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/858
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/858/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/858
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/858/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/858
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/858/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/858
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/858/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-webbrowser-app-ci/581/rebuild

review: Needs Fixing (continuous-integration)

Unmerged revisions

1450. By Alexandre Abreu

Introduce a new extension mechanism for the container that allows webapps to plugin into a discrete set of events coming from the container

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'src/app/webcontainer/UrlFilteringUtils.js'
2--- src/app/webcontainer/UrlFilteringUtils.js 1970-01-01 00:00:00 +0000
3+++ src/app/webcontainer/UrlFilteringUtils.js 2016-05-04 17:07:34 +0000
4@@ -0,0 +1,82 @@
5+/*
6+ * Copyright 2016 Canonical Ltd.
7+ *
8+ * This file is part of webbrowser-app.
9+ *
10+ * webbrowser-app is free software; you can redistribute it and/or modify
11+ * it under the terms of the GNU General Public License as published by
12+ * the Free Software Foundation; version 3.
13+ *
14+ * webbrowser-app is distributed in the hope that it will be useful,
15+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+ * GNU General Public License for more details.
18+ *
19+ * You should have received a copy of the GNU General Public License
20+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21+ */
22+
23+/**
24+ * Takes a URI and submits it to an optional URI filter script
25+ * part of the current webapp. Such scripts are small evaluatable
26+ * javascript files shipped with a webapp that expect a plain uri
27+ * as input and return a triplet:
28+ *
29+ * {
30+ * scheme: <final navigation scheme>
31+ * hostname: <final navigation host name>
32+ * path: <final navigation path>
33+ * }
34+ *
35+ * The result from the optional script is then recomposed to form
36+ * the final URI.
37+ *
38+ * The current URI is used for defaults if the script does not provide
39+ * proper values for the triplet elements.
40+ *
41+ * @param uri URI to be translated
42+ * @param currentUri the reference URI used for defaults
43+ */
44+
45+function translateHandlerUri(uri, currentUri) {
46+ var resolveUriPart = function(uriPart,
47+ fallbackUriForPartExtraction,
48+ fallbackUriPartExtractionPattern) {
49+ var part = ''
50+ if (uriPart && uriPart.length !== 0) {
51+ part = uriPart
52+ }
53+ else if (fallbackUriForPartExtraction) {
54+ var matchPart =
55+ fallbackUriForPartExtraction.match(
56+ fallbackUriPartExtractionPattern)
57+ if (matchPart && matchPart.length > 1) {
58+ part = matchPart[1]
59+ }
60+ }
61+ return part
62+ }
63+
64+ var makeUrlFromResult = function(result) {
65+ var scheme = ''
66+ var hostname = ''
67+ var path = ''
68+
69+ scheme = resolveUriPart(result.scheme, currentUri, /(.*):\/\/[^/]*\/.*/)
70+ hostname = resolveUriPart(result.host, currentUri, /.*:\/\/([^/]*)\/.*/)
71+ path = resolveUriPart(result.path, currentUri, /.*:\/\/[^/]*\/(.*)/)
72+
73+ return scheme + '://'
74+ + hostname + "/"
75+ + path
76+ }
77+
78+ var scheme = uri.substr(0, uri.indexOf(":"))
79+ if (scheme.indexOf("http") === 0 || scheme.indexOf("file:") === 0) {
80+ return uri
81+ }
82+ var result = webappSchemeFilter.applyFilter(uri)
83+ var mapped_uri = makeUrlFromResult(result)
84+ uri = mapped_uri
85+ return uri
86+}
87
88=== modified file 'src/app/webcontainer/WebApp.qml'
89--- src/app/webcontainer/WebApp.qml 2016-04-29 20:19:23 +0000
90+++ src/app/webcontainer/WebApp.qml 2016-05-04 17:07:34 +0000
91@@ -41,6 +41,7 @@
92 property var webappUrlPatterns
93 property alias popupRedirectionUrlPrefixPattern: containerWebView.popupRedirectionUrlPrefixPattern
94 property alias webviewOverrideFile: containerWebView.webviewOverrideFile
95+ property alias webviewExtensionFile: containerWebView.webviewExtensionFile
96 property alias blockOpenExternalUrls: containerWebView.blockOpenExternalUrls
97 property alias localUserAgentOverride: containerWebView.localUserAgentOverride
98 property alias dataPath: containerWebView.dataPath
99
100=== modified file 'src/app/webcontainer/WebViewImplOxide.qml'
101--- src/app/webcontainer/WebViewImplOxide.qml 2016-04-29 20:19:35 +0000
102+++ src/app/webcontainer/WebViewImplOxide.qml 2016-05-04 17:07:34 +0000
103@@ -39,6 +39,7 @@
104 property var mediaAccessDialogComponent
105 property bool openExternalUrlInOverlay: false
106 property bool popupBlockerEnabled: true
107+ property var webviewExtensionHandler
108
109 // Mostly used for testing & avoid external urls to
110 // "leak" in the default browser. External URLs corresponds
111@@ -75,6 +76,14 @@
112
113 currentWebview: webview
114
115+ function evaluateCode(code, wrap) {
116+ webview.rootFrame.sendMessage(
117+ "oxide://webview-server/",
118+ "EVALUATE-CODE",
119+ { code: code,
120+ wrap: wrap === undefined ? false : wrap });
121+ }
122+
123 context: WebContext {
124 dataPath: webview.dataPath
125 userAgent: localUserAgentOverride ? localUserAgentOverride : defaultUserAgent
126@@ -83,6 +92,10 @@
127
128 userScripts: [
129 Oxide.UserScript {
130+ context: "oxide://webview-server/"
131+ url: Qt.resolvedUrl("main-webview-server-script.js")
132+ },
133+ Oxide.UserScript {
134 context: "oxide://webapp-specific-page-metadata-collector/"
135 url: Qt.resolvedUrl("webapp-specific-page-metadata-collector.js")
136 incognitoEnabled: false
137@@ -266,6 +279,13 @@
138 return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview, eventHandlers)
139 }
140
141+ onLoadEvent: {
142+ if (event.type === Oxide.LoadEvent.TypeCommitted
143+ && webviewExtensionHandler) {
144+ webviewExtensionHandler.script.handle('url-loaded', webview, [], webviewExtensionHandler.reply)
145+ }
146+ }
147+
148 function handlePageMetadata(metadata) {
149 if (metadata.type === 'manifest') {
150 var request = new XMLHttpRequest();
151
152=== modified file 'src/app/webcontainer/WebappContainerWebview.qml'
153--- src/app/webcontainer/WebappContainerWebview.qml 2016-04-22 13:52:07 +0000
154+++ src/app/webcontainer/WebappContainerWebview.qml 2016-05-04 17:07:34 +0000
155@@ -22,6 +22,7 @@
156 import Ubuntu.UnityWebApps 0.1 as UnityWebApps
157 import "../actions" as Actions
158 import ".."
159+import "UrlFilteringUtils.js" as UrlFilteringUtils
160
161 Item {
162 id: containerWebview
163@@ -37,6 +38,7 @@
164 property string localUserAgentOverride: ""
165 property string popupRedirectionUrlPrefixPattern: ""
166 property url webviewOverrideFile: ""
167+ property url webviewExtensionFile: ""
168 property bool blockOpenExternalUrls: false
169 property bool runningLocalApplication: false
170 property bool wide: false
171@@ -60,6 +62,10 @@
172 }
173 }
174
175+ // Used for testing
176+ signal schemeUriHandleFilterResult(string uri)
177+ property bool webappExtensionLoaded: false
178+
179 PopupWindowController {
180 id: popupController
181 objectName: "popupController"
182@@ -87,6 +93,40 @@
183 }
184 }
185
186+ /**
187+ * Make sure that all the external URI that we are requested to navigate to
188+ * (via e.g. the UriHandler) are bring translated according
189+ * to an optional filtering script present in the webapp.
190+ * see UrlFilteringUtils.js
191+ *
192+ */
193+ function translateUrl(url) {
194+ var translatedUrl =
195+ UrlFilteringUtils.translateHandlerUri(url)
196+ if (isValidWebviewExtensionHandler(internal.webappExtensionBridgeItem)) {
197+ internal.webappExtensionBridgeItem.script.handle(
198+ 'url-externally-loaded',
199+ webappContainerWebViewLoader.item,
200+ {url: translatedUrl, beforeUrlTranslation: url},
201+ internal.webappExtensionBridgeItem.reply)
202+ }
203+
204+ schemeUriHandleFilterResult(translatedUrl);
205+
206+ return translatedUrl
207+ }
208+
209+ function isValidWebviewExtensionHandler(handler) {
210+ return handler &&
211+ handler.script.handle &&
212+ typeof(handler.script.handle) === 'function'
213+ }
214+
215+ QtObject {
216+ id: internal
217+ property var webappExtensionBridgeItem
218+ }
219+
220 Connections {
221 target: webappContainerWebViewLoader.item
222 onThemeColorMetaInformationDetected: {
223@@ -100,9 +140,24 @@
224 anchors.fill: parent
225 }
226
227- onUrlChanged: if (webappContainerWebViewLoader.item) webappContainerWebViewLoader.item.url = url
228-
229- Component.onCompleted: {
230+ onUrlChanged: {
231+ if (webappContainerWebViewLoader.item) {
232+ var translatedUrl = translateUrl(url)
233+
234+ // Add a small guard to prevent browsing to invalid urls
235+ // since the url will not be part of the usual
236+ // navigationRequested navigation flow and will not
237+ // go through the usual sanity checks
238+ var webview = webappContainerWebViewLoader.item
239+ if (webview.shouldAllowNavigationTo
240+ && !webview.shouldAllowNavigationTo(translatedUrl)) {
241+ return;
242+ }
243+ webview.url = translatedUrl
244+ }
245+ }
246+
247+ function loadWebView(webviewExtensionHandler) {
248 var webappEngineSource = Qt.resolvedUrl("WebViewImplOxide.qml");
249
250 // This is an experimental, UNSUPPORTED, API
251@@ -112,10 +167,11 @@
252 webappEngineSource = webviewOverrideFile;
253 }
254
255+ var translatedUrl = translateUrl(url)
256 webappContainerWebViewLoader.setSource(
257 webappEngineSource,
258 { localUserAgentOverride: containerWebview.localUserAgentOverride
259- , url: containerWebview.url
260+ , url: translatedUrl
261 , webappName: containerWebview.webappName
262 , dataPath: dataPath
263 , webappUrlPatterns: containerWebview.webappUrlPatterns
264@@ -129,6 +185,30 @@
265 , mediaAccessDialogComponent: mediaAccessDialogComponent
266 , openExternalUrlInOverlay: containerWebview.openExternalUrlInOverlay
267 , popupBlockerEnabled: containerWebview.popupBlockerEnabled})
268+ , webviewExtensionHandler: webviewExtensionHandler})
269+ }
270+
271+ Component.onCompleted: {
272+ if (webviewExtensionFile && webviewExtensionFile.toString()) {
273+ internal.webappExtensionBridgeItem =
274+ Qt.createQmlObject(
275+ 'import QtQuick 2.0; '
276+ + 'import "' + webviewExtensionFile.toString() + '" as WebViewExtendScript; '
277+ + 'Item {'
278+ + ' objectName: "webappExtensionRoot"; '
279+ + ' signal reply(string message);'
280+ + ' property var script: WebViewExtendScript '
281+ + '}',
282+ containerWebview)
283+
284+ webappExtensionLoaded = true
285+
286+ loadWebView(
287+ isValidWebviewExtensionHandler(internal.webappExtensionBridgeItem)
288+ ? internal.webappExtensionBridgeItem
289+ : null)
290+ } else {
291+ loadWebView()
292+ }
293 }
294 }
295-
296
297=== added file 'src/app/webcontainer/main-webview-server-script.js'
298--- src/app/webcontainer/main-webview-server-script.js 1970-01-01 00:00:00 +0000
299+++ src/app/webcontainer/main-webview-server-script.js 2016-05-04 17:07:34 +0000
300@@ -0,0 +1,33 @@
301+// vim:expandtab:shiftwidth=2:tabstop=2:
302+// Copyright (C) 201 Canonical Ltd.
303+
304+// This library is free software; you can redistribute it and/or
305+// modify it under the terms of the GNU Lesser General Public
306+// License as published by the Free Software Foundation; either
307+// version 2.1 of the License, or (at your option) any later version.
308+
309+// This library is distributed in the hope that it will be useful,
310+// but WITHOUT ANY WARRANTY; without even the implied warranty of
311+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
312+// Lesser General Public License for more details.
313+
314+// You should have received a copy of the GNU Lesser General Public
315+// License along with this library; if not, write to the Free Software
316+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
317+
318+// ==UserScript==
319+// @run-at document-start
320+// ==/UserScript==
321+
322+oxide.addMessageHandler("EVALUATE-CODE", function(msg) {
323+ var code = msg.payload.code;
324+ if (msg.payload.wrap) {
325+ code = "(function() {" + code + "})()";
326+ }
327+ console.log("EVALUATE-CODE: " + code);
328+ try {
329+ msg.reply({result: eval(code)});
330+ } catch(e) {
331+ msg.error("Code threw exception: \"" + e + "\"");
332+ }
333+});
334
335=== modified file 'src/app/webcontainer/url-pattern-utils.cpp'
336--- src/app/webcontainer/url-pattern-utils.cpp 2015-11-19 15:43:41 +0000
337+++ src/app/webcontainer/url-pattern-utils.cpp 2016-05-04 17:07:34 +0000
338@@ -50,7 +50,7 @@
339 * with those Google service related webapps is that the all rely
340 * on a common authentication mechanism and one endup being redirected
341 * to the auth urls automatically when needed.
342- * Most of the redirections can be match against discrete url patterns
343+ * Most of the redirections can be matched against discrete url patterns
344 * but there is always a country dependant step in the auth patterns, e.g.
345 * https://accounts.google.com/* or https://accounts.google.ca/* etc.
346 *
347
348=== modified file 'src/app/webcontainer/webapp-container.cpp'
349--- src/app/webcontainer/webapp-container.cpp 2016-04-25 17:35:53 +0000
350+++ src/app/webcontainer/webapp-container.cpp 2016-05-04 17:07:34 +0000
351@@ -161,6 +161,13 @@
352 m_window->setProperty("webviewOverrideFile", QUrl::fromLocalFile(overrideFile.absoluteFilePath()));
353 }
354
355+ // Experimental, to offer extension points to the webview key actions
356+ QFileInfo webviewExtensionFile("webview-extend.js");
357+ if (webviewExtensionFile.exists()) {
358+ m_window->setProperty("webviewExtensionFile",
359+ QUrl::fromLocalFile(webviewExtensionFile.absoluteFilePath()));
360+ }
361+
362 const QString WEBAPP_CONTAINER_BLOCK_OPEN_URL_EXTERNALLY_ENV_VAR =
363 qgetenv("WEBAPP_CONTAINER_BLOCK_OPEN_URL_EXTERNALLY");
364 if (WEBAPP_CONTAINER_BLOCK_OPEN_URL_EXTERNALLY_ENV_VAR == "1") {
365@@ -301,6 +308,27 @@
366 out << "Chrome options (if none specified, no chrome is shown by default):" << endl;
367 out << " --enable-back-forward enable the display of the back and forward buttons (implies --enable-addressbar)" << endl;
368 out << " --enable-addressbar enable the display of a minimal chrome (favicon and title)" << endl;
369+ out << endl;
370+ out << "Extension mechanisms:" << endl;
371+ out << " URI filtering: one can setup a local javascript file '" << LOCAL_SCHEME_FILTER_FILENAME << "' that will be used as a filtering" << endl;
372+ out << " step prior to any 'external' non-http URI update. External URI updates correspond to" << endl;
373+ out << " all the URI browsing requests that are not triggered by the user's action while browsing." << endl;
374+ out << " For example: 'mailto:' URIs dispatching from another application." << endl;
375+ out << " The javascript file content should consist of an object listing the supported URI schemes (e.g. 'mailto', 'intent', etc.)" << endl;
376+ out << " each one being associated with a string value corresponding to the function code that is to be executed. The function should expect" << endl;
377+ out << " a URI as input and should return an object consisting of any combination of" << endl;
378+ out << " the desired resulting browsing 'scheme', 'hostname' or/and 'path'. For example:" << endl;
379+ out << endl;
380+ out << " { " << endl;
381+ out << " \"mailto\":" << endl;
382+ out << " \"(function(r) { " << endl;
383+ out << " return { " << endl;
384+ out << " 'scheme': 'https', " << endl;
385+ out << " 'host': 'mail.google.com', " << endl;
386+ out << " 'path': '?to='+encodeURIComponent(r.path)" << endl;
387+ out << " };" << endl;
388+ out << " })\"" << endl;
389+ out << " }" << endl;
390 }
391
392 void WebappContainer::earlyEnvironment()
393
394=== modified file 'src/app/webcontainer/webapp-container.qml'
395--- src/app/webcontainer/webapp-container.qml 2016-04-22 13:52:07 +0000
396+++ src/app/webcontainer/webapp-container.qml 2016-05-04 17:07:34 +0000
397@@ -22,6 +22,7 @@
398 import Ubuntu.Web 0.2
399 import webcontainer.private 0.1
400 import ".."
401+import "UrlFilteringUtils.js" as UrlFilteringUtils
402
403 BrowserWindow {
404 id: root
405@@ -41,6 +42,7 @@
406 property bool accountSwitcher: false
407 property string popupRedirectionUrlPrefixPattern: ""
408 property url webviewOverrideFile: ""
409+ property url webviewExtensionFile: ""
410 property var __webappCookieStore: null
411 property alias webContextSessionCookieMode: webappViewLoader.webContextSessionCookieMode
412 property string localUserAgentOverride: ""
413@@ -54,9 +56,6 @@
414
415 title: getWindowTitle()
416
417- // Used for testing
418- signal schemeUriHandleFilterResult(string uri)
419-
420 function getWindowTitle() {
421 var webappViewTitle =
422 webappViewLoader.item
423@@ -98,6 +97,7 @@
424
425 runningLocalApplication: root.runningLocalApplication
426 webviewOverrideFile: root.webviewOverrideFile
427+ webviewExtensionFile: root.webviewExtensionFile
428
429 anchors.fill: parent
430
431@@ -220,6 +220,7 @@
432
433 function startBrowsing() {
434 console.log("Start browsing")
435+
436 // This will activate the UnityWebApp element used in WebApp.qml
437 webappViewLoader.item.webappName = root.webappName
438
439@@ -229,90 +230,38 @@
440 var webView = webappViewLoader.item.currentWebview
441 var current_url = webView.url.toString();
442 if (!current_url || current_url.length === 0) {
443- webView.url = root.url
444+ webappViewLoader.item.url = root.url
445 }
446 showWebView()
447 }
448
449- function makeUrlFromResult(result) {
450- var scheme = null
451- var hostname = null
452- var url = root.currentWebview.url || root.url
453- if (result.host
454- && result.host.length !== 0) {
455- hostname = result.host
456- }
457- else {
458- var matchHostname = url.toString().match(/.*:\/\/([^/]*)\/.*/)
459- if (matchHostname.length > 1) {
460- hostname = matchHostname[1]
461- }
462- }
463-
464- if (result.scheme
465- && result.scheme.length !== 0) {
466- scheme = result.scheme
467- }
468- else {
469- var matchScheme = url.toString().match(/(.*):\/\/[^/]*\/.*/)
470- if (matchScheme.length > 1) {
471- scheme = matchScheme[1]
472- }
473- }
474- return scheme
475- + '://'
476- + hostname
477- + "/"
478- + (result.path
479- ? result.path : "")
480- }
481-
482- /**
483- *
484- */
485- function translateHandlerUri(uri) {
486- //
487- var scheme = uri.substr(0, uri.indexOf(":"))
488- if (scheme.indexOf("http") === 0) {
489- schemeUriHandleFilterResult(uri)
490- return uri
491- }
492-
493- var result = webappSchemeFilter.applyFilter(uri)
494- var mapped_uri = makeUrlFromResult(result)
495-
496- uri = mapped_uri
497-
498- // Report the result of the intent uri filtering (if any)
499- // Done for testing purposed. It is not possible at this point
500- // to have AP call a slot and retrieve its result synchronously.
501- schemeUriHandleFilterResult(uri)
502-
503- return uri
504- }
505-
506 onOpenUrls: {
507 // only consider the first one (if multiple)
508- if (urls.length === 0 || !root.currentWebview) {
509+ if (uris.length === 0 || !root.currentWebview) {
510 return;
511 }
512- var requestedUrl = urls[0].toString();
513+ var requestedUrl = uris[0].toString();
514
515 if (popupRedirectionUrlPrefixPattern.length !== 0
516 && requestedUrl.match(popupRedirectionUrlPrefixPattern)) {
517 return;
518 }
519
520- requestedUrl = translateHandlerUri(requestedUrl);
521+ var currentUrl = root.currentWebview.url || root.url
522+ requestedUrl =
523+ UrlFilteringUtils.translateHandlerUri(
524+ requestedUrl, currentUrl);
525
526 // Add a small guard to prevent browsing to invalid urls
527- if (currentWebview
528- && currentWebview.shouldAllowNavigationTo
529+ if (currentWebview.shouldAllowNavigationTo
530 && !currentWebview.shouldAllowNavigationTo(requestedUrl)) {
531 return;
532 }
533
534 root.url = requestedUrl
535- root.currentWebview.url = requestedUrl
536+
537+ if (webappViewLoader.item) {
538+ webappViewLoader.item.url = requestedUrl
539+ }
540 }
541 }
542
543=== modified file 'tests/autopilot/webapp_container/tests/__init__.py'
544--- tests/autopilot/webapp_container/tests/__init__.py 2016-01-22 10:19:34 +0000
545+++ tests/autopilot/webapp_container/tests/__init__.py 2016-05-04 17:07:34 +0000
546@@ -76,13 +76,13 @@
547 def get_webcontainer_window(self):
548 return self.app.select_single(objectName="webappContainer")
549
550- def get_webcontainer_webview(self):
551+ def get_webapp_browser_view(self):
552 return self.app.select_single(objectName="webappBrowserView")
553
554 def get_webcontainer_chrome(self):
555 return self.app.select_single("Chrome")
556
557- def get_webview(self):
558+ def get_webcontainer_webview(self):
559 return self.app.select_single(objectName="webview")
560
561 def get_popup_overlay_views(self):
562@@ -92,7 +92,7 @@
563 return self.app.select_single(objectName="popupController")
564
565 def get_oxide_webview(self):
566- container = self.get_webview().select_single(
567+ container = self.get_webcontainer_webview().select_single(
568 objectName='containerWebviewLoader')
569 return container.wait_select_single('WebViewImplOxide')
570
571@@ -105,11 +105,11 @@
572 self.assertThat(webview.loading, Eventually(Equals(False)))
573
574 def get_scheme_filtered_uri(self, uri):
575- webviewContainer = self.get_webcontainer_window()
576+ webviewContainer = self.get_webcontainer_webview()
577 watcher = webviewContainer.watch_signal(
578 'schemeUriHandleFilterResult(QString)')
579 previous = watcher.num_emissions
580- webviewContainer.slots.translateHandlerUri(uri)
581+ webviewContainer.slots.translateUrl(uri)
582 self.assertThat(
583 lambda: watcher.num_emissions,
584 Eventually(GreaterThan(previous)))
585
586=== modified file 'tests/autopilot/webapp_container/tests/fake_servers.py'
587--- tests/autopilot/webapp_container/tests/fake_servers.py 2016-04-22 13:52:07 +0000
588+++ tests/autopilot/webapp_container/tests/fake_servers.py 2016-05-04 17:07:34 +0000
589@@ -35,6 +35,11 @@
590 </head>
591 <body>
592 This is some {} content
593+
594+<a href='/show-user-agent'>
595+<div style="height: 100%; width: 100%">
596+</div>
597+
598 </body>
599 </html>
600 """.format(content)
601
602=== modified file 'tests/autopilot/webapp_container/tests/test_chrome.py'
603--- tests/autopilot/webapp_container/tests/test_chrome.py 2015-03-25 18:00:43 +0000
604+++ tests/autopilot/webapp_container/tests/test_chrome.py 2016-05-04 17:07:34 +0000
605@@ -25,13 +25,13 @@
606 def test_default_to_chromeless(self):
607 self.launch_webcontainer_app_with_local_http_server([])
608 self.assertIsNotNone(self.get_webcontainer_proxy())
609- webview = self.get_webcontainer_webview()
610+ webview = self.get_webapp_browser_view()
611 self.assertThat(webview.chromeless, Equals(True))
612
613 def test_enable_chrome_back_forward(self):
614 args = ['--enable-back-forward']
615 self.launch_webcontainer_app_with_local_http_server(args)
616- webview = self.get_webcontainer_webview()
617+ webview = self.get_webapp_browser_view()
618 self.assertThat(webview.chromeless, Equals(False))
619 chrome = self.get_webcontainer_chrome()
620 self.assertThat(chrome.navigationButtonsVisible, Equals(True))
621@@ -46,7 +46,7 @@
622 args = ['--enable-addressbar']
623 self.launch_webcontainer_app_with_local_http_server(args)
624 self.assertIsNotNone(self.get_webcontainer_proxy())
625- webview = self.get_webcontainer_webview()
626+ webview = self.get_webapp_browser_view()
627 self.assertThat(webview.chromeless, Equals(False))
628
629 def test_reload(self):
630@@ -56,7 +56,7 @@
631
632 self.assert_page_eventually_loaded(self.url)
633
634- container_view = self.get_webcontainer_webview()
635+ container_view = self.get_webapp_browser_view()
636 self.assertThat(container_view.chromeless, Equals(False))
637
638 reload_button = self.app.select_single(objectName="reloadButton")
639
640=== added file 'tests/autopilot/webapp_container/tests/test_container_extension.py'
641--- tests/autopilot/webapp_container/tests/test_container_extension.py 1970-01-01 00:00:00 +0000
642+++ tests/autopilot/webapp_container/tests/test_container_extension.py 2016-05-04 17:07:34 +0000
643@@ -0,0 +1,101 @@
644+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
645+# Copyright 2015 Canonical
646+#
647+# This program is free software: you can redistribute it and/or modify it
648+# under the terms of the GNU General Public License version 3, as published
649+# by the Free Software Foundation.
650+#
651+# This program is distributed in the hope that it will be useful,
652+# but WITHOUT ANY WARRANTY; without even the implied warranty of
653+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
654+# GNU General Public License for more details.
655+#
656+# You should have received a copy of the GNU General Public License
657+# along with this program. If not, see <http://www.gnu.org/licenses/>.
658+
659+from contextlib import contextmanager
660+
661+import os
662+
663+from testtools.matchers import Equals
664+from autopilot.matchers import Eventually
665+
666+from webapp_container.tests import WebappContainerTestCaseWithLocalContentBase
667+
668+
669+@contextmanager
670+def generate_webapp_with_extension(extension_path):
671+ extension_content = """
672+ function handle(message, webview, args, reply) {
673+ reply(message)
674+ }
675+ """
676+ extension_file_path = "{}/webview-extend.js".format(extension_path)
677+ with open(extension_file_path, "w+") as f:
678+ f.write(extension_content)
679+ try:
680+ yield extension_file_path
681+ finally:
682+ os.remove(extension_file_path)
683+
684+
685+class WebappContainerExtensionTestCase(
686+ WebappContainerTestCaseWithLocalContentBase):
687+ def _click_to_browse(self):
688+ webview = self.get_oxide_webview()
689+ gr = webview.globalRect
690+ self.pointing_device.move(
691+ gr.x + webview.width*3/4,
692+ gr.y + webview.height*3/4)
693+ self.pointing_device.click()
694+
695+ def _get_extension_item(self):
696+ return self.app.select_single(objectName="webappExtensionRoot")
697+
698+ def test_extension_not_loaded_by_default(self):
699+ args = []
700+ self.launch_webcontainer_app_with_local_http_server(args)
701+ self.assert_page_eventually_loaded(self.url)
702+
703+ containerWebview = self.get_webcontainer_webview()
704+
705+ self.assertThat(
706+ lambda: containerWebview.webappExtensionLoaded,
707+ Eventually(Equals(False)))
708+
709+ def test_extension_loaded(self):
710+ args = []
711+ with generate_webapp_with_extension(os.getcwd()):
712+ self.launch_webcontainer_app_with_local_http_server(args)
713+ self.assert_page_eventually_loaded(self.url)
714+
715+ containerWebview = self.get_webcontainer_webview()
716+
717+ self.assertThat(
718+ lambda: containerWebview.webappExtensionLoaded,
719+ Eventually(Equals(True)))
720+
721+ def test_extension_called_when_url_changed(self):
722+ args = []
723+ with generate_webapp_with_extension(os.getcwd()):
724+ self.launch_webcontainer_app_with_local_http_server(args)
725+ self.assert_page_eventually_loaded(self.url)
726+
727+ containerWebview = self.get_webcontainer_webview()
728+
729+ self.assertThat(
730+ lambda: containerWebview.webappExtensionLoaded,
731+ Eventually(Equals(True)))
732+
733+ extension = self._get_extension_item()
734+ signal = extension.watch_signal('reply(QString)')
735+
736+ self._click_to_browse()
737+ self.assertThat(
738+ lambda: signal.was_emitted,
739+ Eventually(Equals(True)))
740+ self.assertThat(signal.num_emissions, Equals(1))
741+
742+ received_message = extension.get_signal_emissions(
743+ 'reply(QString)')[-1][0]
744+ self.assertThat(received_message, Equals('url-loaded'))
745
746=== modified file 'tests/autopilot/webapp_container/tests/test_context_menu.py'
747--- tests/autopilot/webapp_container/tests/test_context_menu.py 2016-04-29 20:19:35 +0000
748+++ tests/autopilot/webapp_container/tests/test_context_menu.py 2016-05-04 17:07:34 +0000
749@@ -84,7 +84,7 @@
750 def _dismiss_context_menu(self, menu):
751 if self.get_webcontainer_webview().wide:
752 # Dismiss by clicking outside of the menu
753- webview_rect = self.get_webview().globalRect
754+ webview_rect = self.get_webcontainer_webview().globalRect
755 actions = menu.get_visible_actions()
756 outside_x = (webview_rect.x + actions[0].globalRect.x) // 2
757 outside_y = webview_rect.y + webview_rect.height // 2

Subscribers

People subscribed via source and target branches

to status/vote changes: