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

Side by Side Diff: LayoutTests/http/tests/inspector/network-test.js

Issue 23464028: Add the responseType parameter to InspectorTest.makeXHR (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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 // This goes before everything else to keep console message line number invarian t. 1 // This goes before everything else to keep console message line number invarian t.
2 var lastXHRIndex = 0; 2 var lastXHRIndex = 0;
3 function xhrLoadedCallback() 3 function xhrLoadedCallback()
4 { 4 {
5 // We need to make sure the console message text is unique so that we don't end up with repeat count update only. 5 // We need to make sure the console message text is unique so that we don't end up with repeat count update only.
6 console.log("XHR loaded: " + (++lastXHRIndex)); 6 console.log("XHR loaded: " + (++lastXHRIndex));
7 } 7 }
8 8
9 var initialize_NetworkTest = function() { 9 var initialize_NetworkTest = function() {
10 10
(...skipping 15 matching lines...) Expand all
26 if (!result) { 26 if (!result) {
27 InspectorTest.addResult("This test can not be run as window.internal s is not available."); 27 InspectorTest.addResult("This test can not be run as window.internal s is not available.");
28 Inspector.completeTest(); 28 Inspector.completeTest();
29 } else 29 } else
30 callback(); 30 callback();
31 } 31 }
32 } 32 }
33 33
34 InspectorTest.makeSimpleXHR = function(method, url, async, callback) 34 InspectorTest.makeSimpleXHR = function(method, url, async, callback)
35 { 35 {
36 InspectorTest.makeXHR(method, url, async, undefined, undefined, [], false, u ndefined, callback); 36 InspectorTest.makeXHR(method, url, async, undefined, undefined, [], false, u ndefined, undefined, callback);
37 } 37 }
38 38
39 InspectorTest.makeSimpleXHRWithPayload = function(method, url, async, payload, c allback) 39 InspectorTest.makeSimpleXHRWithPayload = function(method, url, async, payload, c allback)
40 { 40 {
41 InspectorTest.makeXHR(method, url, async, undefined, undefined, [], false, p ayload, callback); 41 InspectorTest.makeXHR(method, url, async, undefined, undefined, [], false, p ayload, undefined, callback);
42 } 42 }
43 43
44 InspectorTest.makeXHR = function(method, url, async, user, password, headers, wi thCredentials, payload, callback) 44 InspectorTest.makeXHR = function(method, url, async, user, password, headers, wi thCredentials, payload, type, callback)
45 { 45 {
46 var args = {}; 46 var args = {};
47 args.method = method; 47 args.method = method;
48 args.url = url; 48 args.url = url;
49 args.async = async; 49 args.async = async;
50 args.user = user; 50 args.user = user;
51 args.password = password; 51 args.password = password;
52 args.headers = headers; 52 args.headers = headers;
53 args.withCredentials = withCredentials; 53 args.withCredentials = withCredentials;
54 args.payload = payload; 54 args.payload = payload;
55 args.type = type;
55 var jsonArgs = JSON.stringify(args).replace(/\"/g, "\\\""); 56 var jsonArgs = JSON.stringify(args).replace(/\"/g, "\\\"");
56 57
57 function innerCallback(msg) 58 function innerCallback(msg)
58 { 59 {
59 if (msg._messageText.indexOf("XHR loaded") !== -1) 60 if (msg._messageText.indexOf("XHR loaded") !== -1)
60 callback(); 61 callback();
61 else 62 else
62 InspectorTest.addConsoleSniffer(innerCallback); 63 InspectorTest.addConsoleSniffer(innerCallback);
63 } 64 }
64 65
65 InspectorTest.addConsoleSniffer(innerCallback); 66 InspectorTest.addConsoleSniffer(innerCallback);
66 InspectorTest.evaluateInPage("makeXHRForJSONArguments(\"" + jsonArgs + "\")" ); 67 InspectorTest.evaluateInPage("makeXHRForJSONArguments(\"" + jsonArgs + "\")" );
67 } 68 }
68 69
69 }; 70 };
70 71
71 function makeSimpleXHR(method, url, async, callback) 72 function makeSimpleXHR(method, url, async, callback)
72 { 73 {
73 makeSimpleXHRWithPayload(method, url, async, null, callback); 74 makeSimpleXHRWithPayload(method, url, async, null, callback);
74 } 75 }
75 76
76 function makeSimpleXHRWithPayload(method, url, async, payload, callback) 77 function makeSimpleXHRWithPayload(method, url, async, payload, callback)
77 { 78 {
78 makeXHR(method, url, async, undefined, undefined, [], false, payload, callba ck) 79 makeXHR(method, url, async, undefined, undefined, [], false, payload, callba ck)
79 } 80 }
80 81
81 function makeXHR(method, url, async, user, password, headers, withCredentials, p ayload, callback) 82 function makeXHR(method, url, async, user, password, headers, withCredentials, p ayload, type, callback)
82 { 83 {
83 var xhr = new XMLHttpRequest(); 84 var xhr = new XMLHttpRequest();
85 xhr.responseType = type;
84 xhr.onreadystatechange = function() 86 xhr.onreadystatechange = function()
85 { 87 {
86 if (xhr.readyState === XMLHttpRequest.DONE) { 88 if (xhr.readyState === XMLHttpRequest.DONE) {
87 if (typeof(callback) === "function") 89 if (typeof(callback) === "function")
88 callback(); 90 callback();
89 } 91 }
90 } 92 }
91 xhr.open(method, url, async, user, password); 93 xhr.open(method, url, async, user, password);
92 xhr.withCredentials = withCredentials; 94 xhr.withCredentials = withCredentials;
93 for (var i = 0; i < headers.length; ++i) 95 for (var i = 0; i < headers.length; ++i)
94 xhr.setRequestHeader(headers[i][0], headers[i][1]); 96 xhr.setRequestHeader(headers[i][0], headers[i][1]);
95 xhr.send(payload); 97 xhr.send(payload);
96 } 98 }
97 99
98 function makeXHRForJSONArguments(jsonArgs) 100 function makeXHRForJSONArguments(jsonArgs)
99 { 101 {
100 var args = JSON.parse(jsonArgs); 102 var args = JSON.parse(jsonArgs);
101 makeXHR(args.method, args.url, args.async, args.user, args.password, args.he aders || [], args.withCredentials, args.payload, xhrLoadedCallback); 103 makeXHR(args.method, args.url, args.async, args.user, args.password, args.he aders || [], args.withCredentials, args.payload, args.type, xhrLoadedCallback);
102 } 104 }
103 105
104 106
105 function resetInspectorResourcesData() 107 function resetInspectorResourcesData()
106 { 108 {
107 if (!window.internals) 109 if (!window.internals)
108 return false; 110 return false;
109 111
110 internals.setInspectorResourcesDataSizeLimits(10 * 1000 * 1000, 1000 * 1000) ; 112 internals.setInspectorResourcesDataSizeLimits(10 * 1000 * 1000, 1000 * 1000) ;
111 return true; 113 return true;
112 } 114 }
113 115
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698