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

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: fix WebRequestRulesRegistrySimpleTest.StageChecker test Created 6 years, 8 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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 chrome.test.listenOnce(chrome.extension.onRequest, function(request) { 593 chrome.test.listenOnce(chrome.extension.onRequest, function(request) {
594 chrome.test.assertTrue(request.pass, "Cookie was not removed."); 594 chrome.test.assertTrue(request.pass, "Cookie was not removed.");
595 }); 595 });
596 chrome.tabs.executeScript(tabId, 596 chrome.tabs.executeScript(tabId,
597 { code: "chrome.extension.sendRequest(" + 597 { code: "chrome.extension.sendRequest(" +
598 "{pass: document.cookie.indexOf('Foo') == -1});" 598 "{pass: document.cookie.indexOf('Foo') == -1});"
599 }); 599 });
600 }); 600 });
601 }, 601 },
602 602
603 // Navigates to a page with a blocking handler that redirects to a different
604 // non-http page during onHeadersReceived. The requested page should not be
605 // loaded, and the redirect should succeed.
606 function simpleLoadRedirectOnReceiveHeaders() {
607 expect(
608 [ // events
609 { label: "onBeforeRequest-1",
610 event: "onBeforeRequest",
611 details: {
612 method: "GET",
613 type: "main_frame",
614 url: getURLHttpSimpleLoad(),
615 frameUrl: getURLHttpSimpleLoad()
616 },
617 },
618 { label: "onBeforeSendHeaders",
619 event: "onBeforeSendHeaders",
620 details: {
621 url: getURLHttpSimpleLoad(),
622 // Note: no requestHeaders because we don't ask for them.
623 },
624 },
625 { label: "onSendHeaders",
626 event: "onSendHeaders",
627 details: {
628 url: getURLHttpSimpleLoad()
629 }
630 },
631 { label: "onHeadersReceived",
632 event: "onHeadersReceived",
633 details: {
634 url: getURLHttpSimpleLoad(),
635 statusLine: "HTTP/1.1 200 OK",
636 },
637 retval: {redirectUrl: getURL("simpleLoad/a.html")}
638 },
639 { label: "onBeforeRedirect",
640 event: "onBeforeRedirect",
641 details: {
642 url: getURLHttpSimpleLoad(),
643 redirectUrl: getURL("simpleLoad/a.html"),
644 statusLine: "HTTP/1.1 302 Found",
645 statusCode: 302,
646 fromCache: false,
647 ip: "127.0.0.1",
648 }
649 },
650 { label: "onBeforeRequest-2",
651 event: "onBeforeRequest",
652 details: {
653 url: getURL("simpleLoad/a.html"),
654 frameUrl: getURL("simpleLoad/a.html"),
655 },
656 },
657 { label: "onResponseStarted",
658 event: "onResponseStarted",
659 details: {
660 url: getURL("simpleLoad/a.html"),
661 fromCache: false,
662 statusCode: 200,
663 statusLine: "HTTP/1.1 200 OK",
664 // Request to chrome-extension:// url has no IP.
665 }
666 },
667 { label: "onCompleted",
668 event: "onCompleted",
669 details: {
670 url: getURL("simpleLoad/a.html"),
671 fromCache: false,
672 statusCode: 200,
673 statusLine: "HTTP/1.1 200 OK",
674 // Request to chrome-extension:// url has no IP.
675 }
676 },
677 ],
678 [ // event order
679 ["onBeforeRequest-1", "onBeforeSendHeaders", "onSendHeaders",
680 "onHeadersReceived", "onBeforeRedirect", "onBeforeRequest-2",
681 "onResponseStarted", "onCompleted"]
682 ],
683 {urls: ["<all_urls>"]}, // filter
684 ["blocking"]);
685 navigateAndWait(getURLHttpSimpleLoad());
686 },
687
603 // Checks that synchronous XHR requests from ourself are invisible to blocking 688 // Checks that synchronous XHR requests from ourself are invisible to blocking
604 // handlers. 689 // handlers.
605 function syncXhrsFromOurselfAreInvisible() { 690 function syncXhrsFromOurselfAreInvisible() {
606 expect( 691 expect(
607 [ // events 692 [ // events
608 { label: "a-onBeforeRequest", 693 { label: "a-onBeforeRequest",
609 event: "onBeforeRequest", 694 event: "onBeforeRequest",
610 details: { 695 details: {
611 url: getURL("simpleLoad/a.html"), 696 url: getURL("simpleLoad/a.html"),
612 frameUrl: getURL("simpleLoad/a.html") 697 frameUrl: getURL("simpleLoad/a.html")
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 // Check the page content for our modified User-Agent string. 931 // Check the page content for our modified User-Agent string.
847 navigateAndWait(getURL("simpleLoad/a.html"), function() { 932 navigateAndWait(getURL("simpleLoad/a.html"), function() {
848 var req = new XMLHttpRequest(); 933 var req = new XMLHttpRequest();
849 var asynchronous = true; 934 var asynchronous = true;
850 req.open("GET", getURLHttpXHRData(), asynchronous); 935 req.open("GET", getURLHttpXHRData(), asynchronous);
851 req.send(null); 936 req.send(null);
852 navigateAndWait(getURL("complexLoad/b.jpg")); 937 navigateAndWait(getURL("complexLoad/b.jpg"));
853 }); 938 });
854 }, 939 },
855 ]); 940 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698