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

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

Issue 28273006: <webview>: Implement declarativeWebRequest API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed browser_tests build Created 7 years, 1 month 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
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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } catch (e) { 321 } catch (e) {
322 embedder.test.fail(); 322 embedder.test.fail();
323 } 323 }
324 }; 324 };
325 webview.addEventListener('newwindow', onNewWindow); 325 webview.addEventListener('newwindow', onNewWindow);
326 326
327 // Load a new window with the given name. 327 // Load a new window with the given name.
328 embedder.setUpNewWindowRequest_(webview, 'guest.html', '', testName); 328 embedder.setUpNewWindowRequest_(webview, 'guest.html', '', testName);
329 } 329 }
330 330
331 // This test verifies that declarative rules added prior to new window
332 // attachment apply correctly.
333 function testNewWindowDeclarativeWebRequest() {
334 var testName = 'testNewWindowWebRequest';
335 var webview = embedder.setUpGuest_('foobar');
336
337 var onNewWindow = function(e) {
338 chrome.test.log('Embedder notified on newwindow');
339 embedder.assertCorrectEvent_(e, '');
340
341 var newwebview = new WebView();
342 var rule = {
343 conditions: [
344 new chrome.webViewRequest.RequestMatcher(
345 {
346 url: { urlContains: 'guest' }
347 }
348 )
349 ],
350 actions: [
351 new chrome.webViewRequest.CancelRequest()
352 ]
353 };
354 newwebview.request.onRequest.addRules([rule]);
Jeffrey Yasskin 2013/11/09 02:47:22 You might have a race condition in that new rules
Fady Samuel 2013/11/10 03:39:56 We add the rule prior to initial navigation. The
Jeffrey Yasskin 2013/11/11 05:37:36 Mhmm. I'm worried that something will happen to yi
355 newwebview.addEventListener('loadabort', function(e) {
356 embedder.test.assertEq('ERR_BLOCKED_BY_CLIENT', e.reason);
357 embedder.test.succeed();
358 });
359 document.querySelector('#webview-tag-container').appendChild(newwebview);
360 e.preventDefault();
361 try {
362 e.window.attach(newwebview);
363 } catch (e) {
364 embedder.test.fail();
365 }
366 };
367 webview.addEventListener('newwindow', onNewWindow);
368
369 // Load a new window with the given name.
370 embedder.setUpNewWindowRequest_(webview, 'guest.html', '', testName);
371 }
372
331 // This test verifies that a WebRequest event listener's lifetime is not 373 // This test verifies that a WebRequest event listener's lifetime is not
332 // tied to the context in which it was created but instead at least the 374 // tied to the context in which it was created but instead at least the
333 // lifetime of the embedder window to which it was attached. 375 // lifetime of the embedder window to which it was attached.
334 function testNewWindowWebRequestCloseWindow() { 376 function testNewWindowWebRequestCloseWindow() {
335 var current = chrome.app.window.current(); 377 var current = chrome.app.window.current();
336 var requestCount = 0; 378 var requestCount = 0;
337 var dataUrl = 'data:text/html,<body>foobar</body>'; 379 var dataUrl = 'data:text/html,<body>foobar</body>';
338 380
339 var webview = new WebView(); 381 var webview = new WebView();
340 webview.request.onBeforeRequest.addListener(function(e) { 382 webview.request.onBeforeRequest.addListener(function(e) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 456 }
415 457
416 embedder.test.testList = { 458 embedder.test.testList = {
417 'testNewWindowNameTakesPrecedence': testNewWindowNameTakesPrecedence, 459 'testNewWindowNameTakesPrecedence': testNewWindowNameTakesPrecedence,
418 'testWebViewNameTakesPrecedence': testWebViewNameTakesPrecedence, 460 'testWebViewNameTakesPrecedence': testWebViewNameTakesPrecedence,
419 'testNoName': testNoName, 461 'testNoName': testNoName,
420 'testNewWindowRedirect': testNewWindowRedirect, 462 'testNewWindowRedirect': testNewWindowRedirect,
421 'testNewWindowClose': testNewWindowClose, 463 'testNewWindowClose': testNewWindowClose,
422 'testNewWindowExecuteScript': testNewWindowExecuteScript, 464 'testNewWindowExecuteScript': testNewWindowExecuteScript,
423 'testNewWindowOpenInNewTab': testNewWindowOpenInNewTab, 465 'testNewWindowOpenInNewTab': testNewWindowOpenInNewTab,
466 'testNewWindowDeclarativeWebRequest': testNewWindowDeclarativeWebRequest,
424 'testNewWindowWebRequest': testNewWindowWebRequest, 467 'testNewWindowWebRequest': testNewWindowWebRequest,
425 'testNewWindowWebRequestCloseWindow': testNewWindowWebRequestCloseWindow, 468 'testNewWindowWebRequestCloseWindow': testNewWindowWebRequestCloseWindow,
426 'testNewWindowWebRequestRemoveElement': testNewWindowWebRequestRemoveElement 469 'testNewWindowWebRequestRemoveElement': testNewWindowWebRequestRemoveElement
427 }; 470 };
428 471
429 onload = function() { 472 onload = function() {
430 chrome.test.getConfig(function(config) { 473 chrome.test.getConfig(function(config) {
431 embedder.setUp_(config); 474 embedder.setUp_(config);
432 chrome.test.sendMessage('Launched'); 475 chrome.test.sendMessage('Launched');
433 }); 476 });
434 }; 477 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698