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

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: Add more tests Created 6 years, 9 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: "HTTP/1.1 307 Temporary Redirect",
563 statusCode: 307,
564 fromCache: false,
565 ip: "127.0.0.1",
566 }
567 },
568 { label: "onBeforeRequest-2",
569 event: "onBeforeRequest",
570 details: {
571 url: getURL("simpleLoad/a.html"),
572 frameUrl: getURL("simpleLoad/a.html"),
573 },
574 },
575 { label: "onResponseStarted",
576 event: "onResponseStarted",
577 details: {
578 url: getURL("simpleLoad/a.html"),
579 fromCache: false,
580 statusCode: 200,
581 statusLine: "HTTP/1.1 200 OK",
582 // Request to chrome-extension:// url has no IP.
583 }
584 },
585 { label: "onCompleted",
586 event: "onCompleted",
587 details: {
588 url: getURL("simpleLoad/a.html"),
589 fromCache: false,
590 statusCode: 200,
591 statusLine: "HTTP/1.1 200 OK",
592 // Request to chrome-extension:// url has no IP.
593 }
594 },
595 ],
596 [ // event order
597 ["onBeforeRequest-1", "onBeforeSendHeaders", "onSendHeaders",
598 "onHeadersReceived", "onBeforeRedirect", "onBeforeRequest-2",
599 "onResponseStarted", "onCompleted"]
600 ],
601 {urls: ["<all_urls>"]}, // filter
602 ["blocking"]);
603 navigateAndWait(getURLHttpSimpleLoad());
604 },
605
521 // Checks that synchronous XHR requests from ourself are invisible to blocking 606 // Checks that synchronous XHR requests from ourself are invisible to blocking
522 // handlers. 607 // handlers.
523 function syncXhrsFromOurselfAreInvisible() { 608 function syncXhrsFromOurselfAreInvisible() {
524 expect( 609 expect(
525 [ // events 610 [ // events
526 { label: "a-onBeforeRequest", 611 { label: "a-onBeforeRequest",
527 event: "onBeforeRequest", 612 event: "onBeforeRequest",
528 details: { 613 details: {
529 url: getURL("simpleLoad/a.html"), 614 url: getURL("simpleLoad/a.html"),
530 frameUrl: getURL("simpleLoad/a.html") 615 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. 849 // Check the page content for our modified User-Agent string.
765 navigateAndWait(getURL("simpleLoad/a.html"), function() { 850 navigateAndWait(getURL("simpleLoad/a.html"), function() {
766 var req = new XMLHttpRequest(); 851 var req = new XMLHttpRequest();
767 var asynchronous = true; 852 var asynchronous = true;
768 req.open("GET", getURLHttpXHRData(), asynchronous); 853 req.open("GET", getURLHttpXHRData(), asynchronous);
769 req.send(null); 854 req.send(null);
770 navigateAndWait(getURL("complexLoad/b.jpg")); 855 navigateAndWait(getURL("complexLoad/b.jpg"));
771 }); 856 });
772 }, 857 },
773 ]); 858 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698