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

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

Issue 16268017: GTTF: convert some tests in chrome to use EmbeddedTestServer patch nr 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 onRequest = chrome.declarativeWebRequest.onRequest; 5 var onRequest = chrome.declarativeWebRequest.onRequest;
6 var AddResponseHeader = 6 var AddResponseHeader =
7 chrome.declarativeWebRequest.AddResponseHeader; 7 chrome.declarativeWebRequest.AddResponseHeader;
8 var RequestMatcher = chrome.declarativeWebRequest.RequestMatcher; 8 var RequestMatcher = chrome.declarativeWebRequest.RequestMatcher;
9 var CancelRequest = chrome.declarativeWebRequest.CancelRequest; 9 var CancelRequest = chrome.declarativeWebRequest.CancelRequest;
10 var RedirectByRegEx = chrome.declarativeWebRequest.RedirectByRegEx; 10 var RedirectByRegEx = chrome.declarativeWebRequest.RedirectByRegEx;
(...skipping 12 matching lines...) Expand all
23 chrome.declarativeWebRequest.IgnoreRules; 23 chrome.declarativeWebRequest.IgnoreRules;
24 var AddRequestCookie = chrome.declarativeWebRequest.AddRequestCookie; 24 var AddRequestCookie = chrome.declarativeWebRequest.AddRequestCookie;
25 var AddResponseCookie = chrome.declarativeWebRequest.AddResponseCookie; 25 var AddResponseCookie = chrome.declarativeWebRequest.AddResponseCookie;
26 var EditRequestCookie = chrome.declarativeWebRequest.EditRequestCookie; 26 var EditRequestCookie = chrome.declarativeWebRequest.EditRequestCookie;
27 var EditResponseCookie = chrome.declarativeWebRequest.EditResponseCookie; 27 var EditResponseCookie = chrome.declarativeWebRequest.EditResponseCookie;
28 var RemoveRequestCookie = chrome.declarativeWebRequest.RemoveRequestCookie; 28 var RemoveRequestCookie = chrome.declarativeWebRequest.RemoveRequestCookie;
29 var RemoveResponseCookie = chrome.declarativeWebRequest.RemoveResponseCookie; 29 var RemoveResponseCookie = chrome.declarativeWebRequest.RemoveResponseCookie;
30 30
31 // Constants as functions, not to be called until after runTests. 31 // Constants as functions, not to be called until after runTests.
32 function getURLHttpSimple() { 32 function getURLHttpSimple() {
33 return getServerURL("files/extensions/api_test/webrequest/simpleLoad/a.html"); 33 return getServerURL("extensions/api_test/webrequest/simpleLoad/a.html");
34 } 34 }
35 35
36 function getURLHttpSimpleB() { 36 function getURLHttpSimpleB() {
37 return getServerURL("files/extensions/api_test/webrequest/simpleLoad/b.html"); 37 return getServerURL("extensions/api_test/webrequest/simpleLoad/b.html");
38 } 38 }
39 39
40 function getURLHttpComplex() { 40 function getURLHttpComplex() {
41 return getServerURL( 41 return getServerURL(
42 "files/extensions/api_test/webrequest/complexLoad/a.html"); 42 "extensions/api_test/webrequest/complexLoad/a.html");
43 } 43 }
44 44
45 function getURLHttpRedirectTest() { 45 function getURLHttpRedirectTest() {
46 return getServerURL( 46 return getServerURL(
47 "files/extensions/api_test/webrequest/declarative/a.html"); 47 "extensions/api_test/webrequest/declarative/a.html");
48 } 48 }
49 49
50 function getURLHttpWithHeaders() { 50 function getURLHttpWithHeaders() {
51 return getServerURL( 51 return getServerURL(
52 "files/extensions/api_test/webrequest/declarative/headers.html"); 52 "extensions/api_test/webrequest/declarative/headers.html");
53 } 53 }
54 54
55 function getURLOfHTMLWithThirdParty() { 55 function getURLOfHTMLWithThirdParty() {
56 // Returns the URL of a HTML document with a third-party resource. 56 // Returns the URL of a HTML document with a third-party resource.
57 return getServerURL( 57 return getServerURL(
58 "files/extensions/api_test/webrequest/declarative/third-party.html"); 58 "extensions/api_test/webrequest/declarative/third-party.html");
59 } 59 }
60 60
61 // Shared test sections. 61 // Shared test sections.
62 function cancelThirdPartyExpected() { 62 function cancelThirdPartyExpected() {
63 return [ 63 return [
64 { label: "onBeforeRequest", 64 { label: "onBeforeRequest",
65 event: "onBeforeRequest", 65 event: "onBeforeRequest",
66 details: { 66 details: {
67 url: getURLOfHTMLWithThirdParty(), 67 url: getURLOfHTMLWithThirdParty(),
68 frameUrl: getURLOfHTMLWithThirdParty() 68 frameUrl: getURLOfHTMLWithThirdParty()
69 } 69 }
70 }, 70 },
71 { label: "onBeforeSendHeaders", 71 { label: "onBeforeSendHeaders",
72 event: "onBeforeSendHeaders", 72 event: "onBeforeSendHeaders",
73 details: {url: getURLOfHTMLWithThirdParty()} 73 details: {url: getURLOfHTMLWithThirdParty()}
74 }, 74 },
75 { label: "onSendHeaders", 75 { label: "onSendHeaders",
76 event: "onSendHeaders", 76 event: "onSendHeaders",
77 details: {url: getURLOfHTMLWithThirdParty()} 77 details: {url: getURLOfHTMLWithThirdParty()}
78 }, 78 },
79 { label: "onHeadersReceived", 79 { label: "onHeadersReceived",
80 event: "onHeadersReceived", 80 event: "onHeadersReceived",
81 details: { 81 details: {
82 url: getURLOfHTMLWithThirdParty(), 82 url: getURLOfHTMLWithThirdParty(),
83 statusLine: "HTTP/1.0 200 OK" 83 statusLine: "HTTP/1.1 200 OK"
84 } 84 }
85 }, 85 },
86 { label: "onResponseStarted", 86 { label: "onResponseStarted",
87 event: "onResponseStarted", 87 event: "onResponseStarted",
88 details: { 88 details: {
89 url: getURLOfHTMLWithThirdParty(), 89 url: getURLOfHTMLWithThirdParty(),
90 fromCache: false, 90 fromCache: false,
91 ip: "127.0.0.1", 91 ip: "127.0.0.1",
92 statusCode: 200, 92 statusCode: 200,
93 statusLine: "HTTP/1.0 200 OK" 93 statusLine: "HTTP/1.1 200 OK"
94 } 94 }
95 }, 95 },
96 { label: "onCompleted", 96 { label: "onCompleted",
97 event: "onCompleted", 97 event: "onCompleted",
98 details: { 98 details: {
99 fromCache: false, 99 fromCache: false,
100 ip: "127.0.0.1", 100 ip: "127.0.0.1",
101 url: getURLOfHTMLWithThirdParty(), 101 url: getURLOfHTMLWithThirdParty(),
102 statusCode: 200, 102 statusCode: 200,
103 statusLine: "HTTP/1.0 200 OK" 103 statusLine: "HTTP/1.1 200 OK"
104 } 104 }
105 }, 105 },
106 { label: "img-onBeforeRequest", 106 { label: "img-onBeforeRequest",
107 event: "onBeforeRequest", 107 event: "onBeforeRequest",
108 details: { 108 details: {
109 type: "image", 109 type: "image",
110 url: "http://non_existing_third_party.com/image.png", 110 url: "http://non_existing_third_party.com/image.png",
111 frameUrl: getURLOfHTMLWithThirdParty() 111 frameUrl: getURLOfHTMLWithThirdParty()
112 } 112 }
113 }, 113 },
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 frameUrl: getURLHttpSimple(), 323 frameUrl: getURLHttpSimple(),
324 }, 324 },
325 }, 325 },
326 { label: "onCompleted", 326 { label: "onCompleted",
327 event: "onCompleted", 327 event: "onCompleted",
328 details: { 328 details: {
329 ip: "127.0.0.1", 329 ip: "127.0.0.1",
330 url: getURLHttpSimple(), 330 url: getURLHttpSimple(),
331 fromCache: false, 331 fromCache: false,
332 statusCode: 200, 332 statusCode: 200,
333 statusLine: "HTTP/1.0 200 OK", 333 statusLine: "HTTP/1.1 200 OK",
334 } 334 }
335 }, 335 },
336 ], 336 ],
337 [ ["onBeforeRequest-a", "onBeforeRedirect", "onBeforeRequest-b", 337 [ ["onBeforeRequest-a", "onBeforeRedirect", "onBeforeRequest-b",
338 "onCompleted"] ]); 338 "onCompleted"] ]);
339 339
340 onRequest.addRules( 340 onRequest.addRules(
341 [ {'conditions': [new RequestMatcher({'url': {'pathSuffix': ".html"}})], 341 [ {'conditions': [new RequestMatcher({'url': {'pathSuffix': ".html"}})],
342 'actions': [ 342 'actions': [
343 new RedirectRequest({'redirectUrl': getURLHttpSimple()})]} 343 new RedirectRequest({'redirectUrl': getURLHttpSimple()})]}
344 ], 344 ],
345 function() {navigateAndWait(getURLHttpComplex());} 345 function() {navigateAndWait(getURLHttpComplex());}
346 ); 346 );
347 }, 347 },
348 348
349 function testRedirectRequest2() { 349 function testRedirectRequest2() {
350 ignoreUnexpected = true; 350 ignoreUnexpected = true;
351 expect( 351 expect(
352 [ 352 [
353 { label: "onCompleted", 353 { label: "onCompleted",
354 event: "onCompleted", 354 event: "onCompleted",
355 details: { 355 details: {
356 ip: "127.0.0.1", 356 ip: "127.0.0.1",
357 url: getURLHttpRedirectTest(), 357 url: getURLHttpRedirectTest(),
358 fromCache: false, 358 fromCache: false,
359 statusCode: 200, 359 statusCode: 200,
360 statusLine: "HTTP/1.0 200 OK", 360 statusLine: "HTTP/1.1 200 OK",
361 } 361 }
362 }, 362 },
363 // We cannot wait for onCompleted signals because these are not sent 363 // We cannot wait for onCompleted signals because these are not sent
364 // for data:// URLs. 364 // for data:// URLs.
365 { label: "onBeforeRedirect-1", 365 { label: "onBeforeRedirect-1",
366 event: "onBeforeRedirect", 366 event: "onBeforeRedirect",
367 details: { 367 details: {
368 url: getServerURL( 368 url: getServerURL(
369 "files/extensions/api_test/webrequest/declarative/image.png"), 369 "extensions/api_test/webrequest/declarative/image.png"),
370 redirectUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEA" + 370 redirectUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEA" +
371 "AAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJ" + 371 "AAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJ" +
372 "ggg==", 372 "ggg==",
373 fromCache: false, 373 fromCache: false,
374 statusCode: -1, 374 statusCode: -1,
375 statusLine: "", 375 statusLine: "",
376 type: "image", 376 type: "image",
377 } 377 }
378 }, 378 },
379 { label: "onBeforeRedirect-2", 379 { label: "onBeforeRedirect-2",
380 event: "onBeforeRedirect", 380 event: "onBeforeRedirect",
381 details: { 381 details: {
382 frameId: 1, 382 frameId: 1,
383 parentFrameId: 0, 383 parentFrameId: 0,
384 url: getServerURL( 384 url: getServerURL(
385 "files/extensions/api_test/webrequest/declarative/frame.html"), 385 "extensions/api_test/webrequest/declarative/frame.html"),
386 redirectUrl: "data:text/html,", 386 redirectUrl: "data:text/html,",
387 fromCache: false, 387 fromCache: false,
388 statusCode: -1, 388 statusCode: -1,
389 statusLine: "", 389 statusLine: "",
390 type: "sub_frame", 390 type: "sub_frame",
391 } 391 }
392 }, 392 },
393 ], 393 ],
394 [ ["onCompleted"], ["onBeforeRedirect-1"], ["onBeforeRedirect-2"] ]); 394 [ ["onCompleted"], ["onBeforeRedirect-1"], ["onBeforeRedirect-2"] ]);
395 395
(...skipping 13 matching lines...) Expand all
409 ignoreUnexpected = true; 409 ignoreUnexpected = true;
410 expect( 410 expect(
411 [ 411 [
412 { label: "onCompleted", 412 { label: "onCompleted",
413 event: "onCompleted", 413 event: "onCompleted",
414 details: { 414 details: {
415 ip: "127.0.0.1", 415 ip: "127.0.0.1",
416 url: getURLHttpSimpleB(), 416 url: getURLHttpSimpleB(),
417 fromCache: false, 417 fromCache: false,
418 statusCode: 200, 418 statusCode: 200,
419 statusLine: "HTTP/1.0 200 OK", 419 statusLine: "HTTP/1.1 200 OK",
420 } 420 }
421 }, 421 },
422 ], 422 ],
423 [ ["onCompleted"] ]); 423 [ ["onCompleted"] ]);
424 424
425 onRequest.addRules( 425 onRequest.addRules(
426 [ {conditions: [new RequestMatcher({url: {pathSuffix: ".html"}})], 426 [ {conditions: [new RequestMatcher({url: {pathSuffix: ".html"}})],
427 actions: [ 427 actions: [
428 new RedirectByRegEx({from: "^(.*)/a.html$", to: "$1/b.html"})]} 428 new RedirectByRegEx({from: "^(.*)/a.html$", to: "$1/b.html"})]}
429 ], 429 ],
(...skipping 22 matching lines...) Expand all
452 'urlMatches': 'simple[A-Z].*a\.html$', 452 'urlMatches': 'simple[A-Z].*a\.html$',
453 'schemes': ["http"] 453 'schemes': ["http"]
454 }, 454 },
455 })], 455 })],
456 'actions': [new CancelRequest()]} 456 'actions': [new CancelRequest()]}
457 ], 457 ],
458 function() {navigateAndWait(getURLHttpSimple());} 458 function() {navigateAndWait(getURLHttpSimple());}
459 ); 459 );
460 }, 460 },
461 ]); 461 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698