| Index: chrome/test/data/extensions/platform_apps/web_view/newwindow/embedder.js
|
| diff --git a/chrome/test/data/extensions/platform_apps/web_view/newwindow/embedder.js b/chrome/test/data/extensions/platform_apps/web_view/newwindow/embedder.js
|
| index 7a5fb27a4870b77c69dc1a21ed3ee874b695edfc..5230de17555145f49e8e792f7c2fef013f81121a 100644
|
| --- a/chrome/test/data/extensions/platform_apps/web_view/newwindow/embedder.js
|
| +++ b/chrome/test/data/extensions/platform_apps/web_view/newwindow/embedder.js
|
| @@ -6,6 +6,7 @@ var embedder = {};
|
| embedder.test = {};
|
| embedder.baseGuestURL = '';
|
| embedder.guestURL = '';
|
| +embedder.newWindowURL = '';
|
|
|
| window.runTest = function(testName) {
|
| if (!embedder.test.testList[testName]) {
|
| @@ -25,6 +26,9 @@ embedder.setUp_ = function(config) {
|
| embedder.guestURL = embedder.baseGuestURL +
|
| '/extensions/platform_apps/web_view/newwindow' +
|
| '/guest_opener.html';
|
| + embedder.newWindowURL = embedder.baseGuestURL +
|
| + '/extensions/platform_apps/web_view/newwindow' +
|
| + '/newwindow.html';
|
| chrome.test.log('Guest url is: ' + embedder.guestURL);
|
| };
|
|
|
| @@ -354,6 +358,44 @@ function testNewWindowWebRequestRemoveElement() {
|
| embedder.setUpNewWindowRequest_(webview, 'guest.html', '', testName);
|
| };
|
|
|
| +// This test verifies that a WebRequest event listener's lifetime is not
|
| +// tied to the context in which it was created but instead at least the
|
| +// lifetime of the embedder window to which it was attached.
|
| +function testNewWindowWebRequestCloseWindow() {
|
| + var current = chrome.app.window.current();
|
| + var requestCount = 0;
|
| + var dataUrl = 'data:text/html,<body>foobar</body>';
|
| +
|
| + var webview = new WebView();
|
| + webview.request.onBeforeRequest.addListener(function(e) {
|
| + console.log('url: ' + e.url);
|
| + ++requestCount;
|
| + if (requestCount == 1) {
|
| + // Close the existing window.
|
| + // TODO(fsamuel): This is currently broken and this test is disabled.
|
| + // Once we close the first window, the context in which the <webview> was
|
| + // created is gone and so the <webview> is no longer a custom element.
|
| + current.close();
|
| + // renavigate the webview.
|
| + webview.src = embedder.newWindowURL;
|
| + } else if (requestCount == 2) {
|
| + embedder.test.succeed();
|
| + }
|
| + }, {urls: ['<all_urls>']});
|
| + webview.addEventListener('loadcommit', function(e) {
|
| + console.log('loadcommit: ' + e.url);
|
| + });
|
| + webview.src = embedder.guestURL;
|
| +
|
| + chrome.app.window.create('newwindow.html', {
|
| + width: 640,
|
| + height: 480
|
| + }, function(newwindow) {
|
| + newwindow.contentWindow.onload = function(evt) {
|
| + newwindow.contentWindow.document.body.appendChild(webview);
|
| + };
|
| + });
|
| +};
|
|
|
| embedder.test.testList = {
|
| 'testNewWindowNameTakesPrecedence': testNewWindowNameTakesPrecedence,
|
| @@ -363,7 +405,8 @@ embedder.test.testList = {
|
| 'testNewWindowClose': testNewWindowClose,
|
| 'testNewWindowExecuteScript': testNewWindowExecuteScript,
|
| 'testNewWindowWebRequest': testNewWindowWebRequest,
|
| - 'testNewWindowWebRequestRemoveElement': testNewWindowWebRequestRemoveElement
|
| + 'testNewWindowWebRequestRemoveElement': testNewWindowWebRequestRemoveElement,
|
| + 'testNewWindowWebRequestCloseWindow': testNewWindowWebRequestCloseWindow
|
| };
|
|
|
| onload = function() {
|
|
|