Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1049)

Side by Side Diff: chrome/test/data/extensions/platform_apps/web_view/newwindow/embedder.js

Issue 497833003: <webview>: Add test coverage for deferred newwindow attachment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/renderer/resources/extensions/web_view.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var embedder = {}; 5 var embedder = {};
6 embedder.test = {}; 6 embedder.test = {};
7 embedder.baseGuestURL = ''; 7 embedder.baseGuestURL = '';
8 embedder.guestURL = ''; 8 embedder.guestURL = '';
9 embedder.guestWithLinkURL = ''; 9 embedder.guestWithLinkURL = '';
10 embedder.newWindowURL = ''; 10 embedder.newWindowURL = '';
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } catch (e) { 251 } catch (e) {
252 embedder.test.fail(); 252 embedder.test.fail();
253 } 253 }
254 }; 254 };
255 webview.addEventListener('newwindow', onNewWindow); 255 webview.addEventListener('newwindow', onNewWindow);
256 256
257 // Load a new window with the given name. 257 // Load a new window with the given name.
258 embedder.setUpNewWindowRequest_(webview, 'guest.html', '', testName); 258 embedder.setUpNewWindowRequest_(webview, 'guest.html', '', testName);
259 } 259 }
260 260
261 // Checks that calling event.window.attach() with a <webview> that is not
262 // in the DOM works properly.
263 // This tests the deferred attachment code path in web_view.js.
264 function testNewWindowDeferredAttachment() {
265 var testName = 'testNewWindowDeferredAttachment';
266 var webview = embedder.setUpGuest_('foobar');
267
268 var onNewWindow = function(e) {
269 chrome.test.log('Embedder notified on newwindow');
270 embedder.assertCorrectEvent_(e, '');
271
272 var newwebview = document.createElement('webview');
273
274 newwebview.addEventListener('loadstop', function() {
275 chrome.test.log('Guest in newwindow got loadstop.');
276 embedder.test.succeed();
277 });
278
279 try {
280 e.window.attach(newwebview);
281 } catch (e) {
282 embedder.test.fail();
283 }
284
285 // Append the <webview> in DOM later.
286 window.setTimeout(function() {
287 document.querySelector('#webview-tag-container').appendChild(newwebview);
288 }, 0);
289 };
290 webview.addEventListener('newwindow', onNewWindow);
291
292 // Load a new window with the given name.
293 embedder.setUpNewWindowRequest_(webview, 'guest.html', '', testName);
294 };
295
261 function testNewWindowExecuteScript() { 296 function testNewWindowExecuteScript() {
262 var testName = 'testNewWindowExecuteScript'; 297 var testName = 'testNewWindowExecuteScript';
263 var webview = embedder.setUpGuest_('foobar'); 298 var webview = embedder.setUpGuest_('foobar');
264 299
265 var onNewWindow = function(e) { 300 var onNewWindow = function(e) {
266 chrome.test.log('Embedder notified on newwindow'); 301 chrome.test.log('Embedder notified on newwindow');
267 embedder.assertCorrectEvent_(e, ''); 302 embedder.assertCorrectEvent_(e, '');
268 303
269 var newwebview = document.createElement('webview'); 304 var newwebview = document.createElement('webview');
270 document.querySelector('#webview-tag-container').appendChild(newwebview); 305 document.querySelector('#webview-tag-container').appendChild(newwebview);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 // Load a new window with the given name. 489 // Load a new window with the given name.
455 embedder.setUpNewWindowRequest_(webview, 'guest.html', '', testName); 490 embedder.setUpNewWindowRequest_(webview, 'guest.html', '', testName);
456 } 491 }
457 492
458 embedder.test.testList = { 493 embedder.test.testList = {
459 'testNewWindowNameTakesPrecedence': testNewWindowNameTakesPrecedence, 494 'testNewWindowNameTakesPrecedence': testNewWindowNameTakesPrecedence,
460 'testWebViewNameTakesPrecedence': testWebViewNameTakesPrecedence, 495 'testWebViewNameTakesPrecedence': testWebViewNameTakesPrecedence,
461 'testNoName': testNoName, 496 'testNoName': testNoName,
462 'testNewWindowRedirect': testNewWindowRedirect, 497 'testNewWindowRedirect': testNewWindowRedirect,
463 'testNewWindowClose': testNewWindowClose, 498 'testNewWindowClose': testNewWindowClose,
499 'testNewWindowDeferredAttachment': testNewWindowDeferredAttachment,
464 'testNewWindowExecuteScript': testNewWindowExecuteScript, 500 'testNewWindowExecuteScript': testNewWindowExecuteScript,
465 'testNewWindowOpenInNewTab': testNewWindowOpenInNewTab, 501 'testNewWindowOpenInNewTab': testNewWindowOpenInNewTab,
466 'testNewWindowDeclarativeWebRequest': testNewWindowDeclarativeWebRequest, 502 'testNewWindowDeclarativeWebRequest': testNewWindowDeclarativeWebRequest,
467 'testNewWindowWebRequest': testNewWindowWebRequest, 503 'testNewWindowWebRequest': testNewWindowWebRequest,
468 'testNewWindowWebRequestCloseWindow': testNewWindowWebRequestCloseWindow, 504 'testNewWindowWebRequestCloseWindow': testNewWindowWebRequestCloseWindow,
469 'testNewWindowWebRequestRemoveElement': testNewWindowWebRequestRemoveElement 505 'testNewWindowWebRequestRemoveElement': testNewWindowWebRequestRemoveElement
470 }; 506 };
471 507
472 onload = function() { 508 onload = function() {
473 chrome.test.getConfig(function(config) { 509 chrome.test.getConfig(function(config) {
474 embedder.setUp_(config); 510 embedder.setUp_(config);
475 chrome.test.sendMessage('Launched'); 511 chrome.test.sendMessage('Launched');
476 }); 512 });
477 }; 513 };
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/web_view.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698