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

Side by Side Diff: chrome/test/data/extensions/api_test/webrequest/events/test.html

Issue 7528025: Revert 95986 - Add support for XMLHttpRequests to the webRequest API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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 <script> 1 <script>
2 var getURL = chrome.extension.getURL; 2 var getURL = chrome.extension.getURL;
3 var deepEq = chrome.test.checkDeepEq; 3 var deepEq = chrome.test.checkDeepEq;
4 var expectedEventData; 4 var expectedEventData;
5 var capturedEventData; 5 var capturedEventData;
6 var expectedEventOrder; 6 var expectedEventOrder;
7 var tabId; 7 var tabId;
8 var eventsCaptured; 8 var eventsCaptured;
9 9
10 // PORT will be changed to the port of the test server. 10 // PORT will be changed to the port of the test server.
11 var URL_HTTP_SIMPLE_LOAD = 11 var URL_HTTP_SIMPLE_LOAD =
12 'http://www.a.com:PORT/files/extensions/api_test/webrequest/events/simpleLoa d/a.html'; 12 'http://www.a.com:PORT/files/extensions/api_test/webrequest/events/simpleLoa d/a.html';
13 var URL_HTTP_SIMPLE_LOAD_REDIRECT = 13 var URL_HTTP_SIMPLE_LOAD_REDIRECT =
14 'http://www.a.com:PORT/server-redirect?'+URL_HTTP_SIMPLE_LOAD; 14 'http://www.a.com:PORT/server-redirect?'+URL_HTTP_SIMPLE_LOAD;
15 var URL_ECHO_USER_AGENT = 15 var URL_ECHO_USER_AGENT =
16 'http://www.a.com:PORT/echoheader?User-Agent'; 16 'http://www.a.com:PORT/echoheader?User-Agent';
17 var URL_AUTH_REQUIRED = 17 var URL_AUTH_REQUIRED =
18 'http://www.a.com:PORT/auth-basic'; 18 'http://www.a.com:PORT/auth-basic';
19 var URL_HTTP_XHR =
20 'http://www.a.com:PORT/files/extensions/api_test/webrequest/events/xhr/a.htm l';
21 var URL_HTTP_XHR_DATA =
22 'http://www.a.com:PORT/files/extensions/api_test/webrequest/events/xhr/data. json';
23 19
24 function runTests(tests) { 20 function runTests(tests) {
25 chrome.tabs.getSelected(null, function(tab) { 21 chrome.tabs.getSelected(null, function(tab) {
26 tabId = tab.id; 22 tabId = tab.id;
27 chrome.test.getConfig(function(config) { 23 chrome.test.getConfig(function(config) {
28 var fixPort = function(url) { 24 var fixPort = function(url) {
29 return url.replace(/PORT/g, config.testServer.port); 25 return url.replace(/PORT/g, config.testServer.port);
30 }; 26 };
31 URL_HTTP_SIMPLE_LOAD = fixPort(URL_HTTP_SIMPLE_LOAD); 27 URL_HTTP_SIMPLE_LOAD = fixPort(URL_HTTP_SIMPLE_LOAD);
32 URL_HTTP_SIMPLE_LOAD_REDIRECT = fixPort(URL_HTTP_SIMPLE_LOAD_REDIRECT); 28 URL_HTTP_SIMPLE_LOAD_REDIRECT = fixPort(URL_HTTP_SIMPLE_LOAD_REDIRECT);
33 URL_ECHO_USER_AGENT = fixPort(URL_ECHO_USER_AGENT); 29 URL_ECHO_USER_AGENT = fixPort(URL_ECHO_USER_AGENT);
34 URL_AUTH_REQUIRED = fixPort(URL_AUTH_REQUIRED); 30 URL_AUTH_REQUIRED = fixPort(URL_AUTH_REQUIRED);
35 URL_HTTP_XHR = fixPort(URL_HTTP_XHR);
36 URL_HTTP_XHR_DATA = fixPort(URL_HTTP_XHR_DATA);
37 31
38 chrome.test.runTests(tests); 32 chrome.test.runTests(tests);
39 }); 33 });
40 }); 34 });
41 } 35 }
42 36
43 // Helper to advance to the next test only when the tab has finished loading. 37 // Helper to advance to the next test only when the tab has finished loading.
44 // This is because tabs.update can sometimes fail if the tab is in the middle 38 // This is because tabs.update can sometimes fail if the tab is in the middle
45 // of a navigation (from the previous test), resulting in flakiness. 39 // of a navigation (from the previous test), resulting in flakiness.
46 function navigateAndWait(url, callback) { 40 function navigateAndWait(url, callback) {
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 [ // event order 375 [ // event order
382 ["onBeforeRequest-1", "onBeforeSendHeaders-1", "onSendHeaders-1", 376 ["onBeforeRequest-1", "onBeforeSendHeaders-1", "onSendHeaders-1",
383 "onBeforeRedirect", 377 "onBeforeRedirect",
384 "onBeforeRequest-2", "onBeforeSendHeaders-2", "onSendHeaders-2", 378 "onBeforeRequest-2", "onBeforeSendHeaders-2", "onSendHeaders-2",
385 "onResponseStarted", "onCompleted"] ], 379 "onResponseStarted", "onCompleted"] ],
386 {}, // filter 380 {}, // filter
387 ["requestHeaders", "responseHeaders", "statusLine"]); 381 ["requestHeaders", "responseHeaders", "statusLine"]);
388 navigateAndWait(URL_HTTP_SIMPLE_LOAD_REDIRECT); 382 navigateAndWait(URL_HTTP_SIMPLE_LOAD_REDIRECT);
389 }, 383 },
390 384
391 // Navigates to a page to generates an XHR.
392 function xhrLoad() {
393 expect(
394 [ // events
395 { label: "onBeforeRequest-1",
396 event: "onBeforeRequest",
397 details: {
398 method: "GET",
399 tabId: tabId,
400 type: "main_frame",
401 url: URL_HTTP_XHR,
402 frameUrl: URL_HTTP_XHR
403 }
404 },
405 { label: "onBeforeSendHeaders-1",
406 event: "onBeforeSendHeaders",
407 details: {
408 url: URL_HTTP_XHR,
409 }
410 },
411 { label: "onSendHeaders-1",
412 event: "onSendHeaders",
413 details: {
414 url: URL_HTTP_XHR,
415 }
416 },
417 { label: "onResponseStarted-1",
418 event: "onResponseStarted",
419 details: {
420 url: URL_HTTP_XHR,
421 statusCode: 200,
422 ip: "127.0.0.1",
423 fromCache: false,
424 }
425 },
426 { label: "onCompleted-1",
427 event: "onCompleted",
428 details: {
429 url: URL_HTTP_XHR,
430 statusCode: 200,
431 ip: "127.0.0.1",
432 fromCache: false,
433 }
434 },
435 { label: "onBeforeRequest-2",
436 event: "onBeforeRequest",
437 details: {
438 method: "GET",
439 tabId: tabId,
440 type: "xmlhttprequest",
441 url: URL_HTTP_XHR_DATA,
442 frameUrl: URL_HTTP_XHR
443 }
444 },
445 { label: "onBeforeSendHeaders-2",
446 event: "onBeforeSendHeaders",
447 details: {
448 url: URL_HTTP_XHR_DATA,
449 }
450 },
451 { label: "onSendHeaders-2",
452 event: "onSendHeaders",
453 details: {
454 url: URL_HTTP_XHR_DATA,
455 }
456 },
457 { label: "onResponseStarted-2",
458 event: "onResponseStarted",
459 details: {
460 url: URL_HTTP_XHR_DATA,
461 statusCode: 200,
462 ip: "127.0.0.1",
463 fromCache: false,
464 }
465 },
466 { label: "onCompleted-2",
467 event: "onCompleted",
468 details: {
469 url: URL_HTTP_XHR_DATA,
470 statusCode: 200,
471 ip: "127.0.0.1",
472 fromCache: false,
473 }
474 }
475 ],
476 [ // event order
477 ["onBeforeRequest-1", "onBeforeSendHeaders-1", "onSendHeaders-1",
478 "onResponseStarted-1", "onCompleted-1",
479 "onBeforeRequest-2", "onBeforeSendHeaders-2", "onSendHeaders-2",
480 "onResponseStarted-2", "onCompleted-2"] ],
481 {}, []);
482 navigateAndWait(URL_HTTP_XHR);
483 },
484
485 // Navigates to a page with subresources. 385 // Navigates to a page with subresources.
486 // TODO(mpcomplete): add multiple subresources; requires support for 386 // TODO(mpcomplete): add multiple subresources; requires support for
487 // recognizing partial ordering. 387 // recognizing partial ordering.
488 function complexLoad() { 388 function complexLoad() {
489 expect( 389 expect(
490 [ // events 390 [ // events
491 { label: "a.html-onBeforeRequest", 391 { label: "a.html-onBeforeRequest",
492 event: "onBeforeRequest", 392 event: "onBeforeRequest",
493 details: { 393 details: {
494 method: "GET", 394 method: "GET",
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 ], 819 ],
920 [ // event order 820 [ // event order
921 ["onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders", 821 ["onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders",
922 "onAuthRequired", "onResponseStarted", "onCompleted"] 822 "onAuthRequired", "onResponseStarted", "onCompleted"]
923 ], 823 ],
924 {}, []); 824 {}, []);
925 navigateAndWait(URL_AUTH_REQUIRED); 825 navigateAndWait(URL_AUTH_REQUIRED);
926 }, 826 },
927 ]); 827 ]);
928 </script> 828 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698