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

Side by Side Diff: chrome/test/data/extensions/api_test/webrequest/test_blocking.js

Issue 154473002: Support redirectUrl at onHeadersReceived in WebRequest / DWR API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 6 years, 10 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 pass = chrome.test.callbackPass; 5 var pass = chrome.test.callbackPass;
6 6
7 // Constants as functions, not to be called until after runTests. 7 // Constants as functions, not to be called until after runTests.
8 function getURLEchoUserAgent() { 8 function getURLEchoUserAgent() {
9 return getServerURL('echoheader?User-Agent'); 9 return getServerURL('echoheader?User-Agent');
10 } 10 }
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 chrome.test.listenOnce(chrome.extension.onRequest, function(request) { 511 chrome.test.listenOnce(chrome.extension.onRequest, function(request) {
512 chrome.test.assertTrue(request.pass, "Cookie was not removed."); 512 chrome.test.assertTrue(request.pass, "Cookie was not removed.");
513 }); 513 });
514 chrome.tabs.executeScript(tabId, 514 chrome.tabs.executeScript(tabId,
515 { code: "chrome.extension.sendRequest(" + 515 { code: "chrome.extension.sendRequest(" +
516 "{pass: document.cookie.indexOf('Foo') == -1});" 516 "{pass: document.cookie.indexOf('Foo') == -1});"
517 }); 517 });
518 }); 518 });
519 }, 519 },
520 520
521 // Navigates to a page with a blocking handler that redirects to a different
522 // non-http page during onHeadersReceived. The requested page should not be
523 // loaded, and the redirect should succeed.
524 function simpleLoadRedirectOnReceiveHeaders() {
525 expect(
526 [ // events
527 { label: "onBeforeRequest-1",
528 event: "onBeforeRequest",
529 details: {
530 method: "GET",
531 type: "main_frame",
532 url: getURLHttpSimpleLoad(),
533 frameUrl: getURLHttpSimpleLoad()
534 },
535 },
536 { label: "onBeforeSendHeaders",
537 event: "onBeforeSendHeaders",
538 details: {
539 url: getURLHttpSimpleLoad(),
540 // Note: no requestHeaders because we don't ask for them.
541 },
542 },
543 { label: "onSendHeaders",
544 event: "onSendHeaders",
545 details: {
546 url: getURLHttpSimpleLoad()
547 }
548 },
549 { label: "onHeadersReceived",
550 event: "onHeadersReceived",
551 details: {
552 url: getURLHttpSimpleLoad(),
553 statusLine: "HTTP/1.1 200 OK",
554 },
555 retval: {redirectUrl: getURL("simpleLoad/a.html")}
556 },
557 { label: "onBeforeRedirect",
558 event: "onBeforeRedirect",
559 details: {
560 url: getURLHttpSimpleLoad(),
561 redirectUrl: getURL("simpleLoad/a.html"),
562 statusLine: "",
563 statusCode: -1,
564 fromCache: false,
565 }
566 },
567 { label: "onBeforeRequest-2",
568 event: "onBeforeRequest",
569 details: {
570 url: getURL("simpleLoad/a.html"),
571 frameUrl: getURL("simpleLoad/a.html"),
572 },
573 },
574 { label: "onResponseStarted",
575 event: "onResponseStarted",
576 details: {
577 url: getURL("simpleLoad/a.html"),
578 fromCache: false,
579 statusCode: 200,
580 statusLine: "HTTP/1.1 200 OK",
581 // Request to chrome-extension:// url has no IP.
582 }
583 },
584 { label: "onCompleted",
585 event: "onCompleted",
586 details: {
587 url: getURL("simpleLoad/a.html"),
588 fromCache: false,
589 statusCode: 200,
590 statusLine: "HTTP/1.1 200 OK",
591 // Request to chrome-extension:// url has no IP.
592 }
593 },
594 ],
595 [ // event order
596 ["onBeforeRequest-1", "onBeforeSendHeaders", "onSendHeaders",
597 "onHeadersReceived", "onBeforeRedirect", "onBeforeRequest-2",
598 "onResponseStarted", "onCompleted"]
599 ],
600 {urls: ["<all_urls>"]}, // filter
601 ["blocking"]);
602 navigateAndWait(getURLHttpSimpleLoad());
603 },
604
521 // Checks that synchronous XHR requests from ourself are invisible to blocking 605 // Checks that synchronous XHR requests from ourself are invisible to blocking
522 // handlers. 606 // handlers.
523 function syncXhrsFromOurselfAreInvisible() { 607 function syncXhrsFromOurselfAreInvisible() {
524 expect( 608 expect(
525 [ // events 609 [ // events
526 { label: "a-onBeforeRequest", 610 { label: "a-onBeforeRequest",
527 event: "onBeforeRequest", 611 event: "onBeforeRequest",
528 details: { 612 details: {
529 url: getURL("simpleLoad/a.html"), 613 url: getURL("simpleLoad/a.html"),
530 frameUrl: getURL("simpleLoad/a.html") 614 frameUrl: getURL("simpleLoad/a.html")
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 // Check the page content for our modified User-Agent string. 848 // Check the page content for our modified User-Agent string.
765 navigateAndWait(getURL("simpleLoad/a.html"), function() { 849 navigateAndWait(getURL("simpleLoad/a.html"), function() {
766 var req = new XMLHttpRequest(); 850 var req = new XMLHttpRequest();
767 var asynchronous = true; 851 var asynchronous = true;
768 req.open("GET", getURLHttpXHRData(), asynchronous); 852 req.open("GET", getURLHttpXHRData(), asynchronous);
769 req.send(null); 853 req.send(null);
770 navigateAndWait(getURL("complexLoad/b.jpg")); 854 navigateAndWait(getURL("complexLoad/b.jpg"));
771 }); 855 });
772 }, 856 },
773 ]); 857 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698