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

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

Issue 1259393002: DevTools: add support for logging fetch requests when XHR logging is enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fixed the test Created 5 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
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 function makeSimpleXHR(method, url, async, callback)
10 {
11 makeSimpleXHRWithPayload(method, url, async, null, callback);
12 }
13
14 function makeSimpleXHRWithPayload(method, url, async, payload, callback)
15 {
16 makeXHR(method, url, async, undefined, undefined, [], false, payload, callba ck)
17 }
18
19 function makeXHR(method, url, async, user, password, headers, withCredentials, p ayload, type, callback)
20 {
21 var xhr = new XMLHttpRequest();
22 if (type == undefined)
23 xhr.responseType = "";
24 else
25 xhr.responseType = type;
26 xhr.onreadystatechange = function()
27 {
28 if (xhr.readyState === XMLHttpRequest.DONE) {
29 if (typeof(callback) === "function")
30 callback();
31 }
32 }
33 xhr.open(method, url, async, user, password);
34 xhr.withCredentials = withCredentials;
35 for (var i = 0; i < headers.length; ++i)
36 xhr.setRequestHeader(headers[i][0], headers[i][1]);
37 xhr.send(payload);
38 }
39
40 function makeXHRForJSONArguments(jsonArgs)
41 {
42 var args = JSON.parse(jsonArgs);
43 makeXHR(args.method, args.url, args.async, args.user, args.password, args.he aders || [], args.withCredentials, args.payload, args.type, xhrLoadedCallback);
44 }
45
46 function makeFetch(url, requestInitializer, callback)
47 {
48 fetch(url, requestInitializer).then(callback).catch(callback);
49 }
50
9 var initialize_NetworkTest = function() { 51 var initialize_NetworkTest = function() {
10 52
11 InspectorTest.preloadPanel("network"); 53 InspectorTest.preloadPanel("network");
12 54
13 InspectorTest.recordNetwork = function() 55 InspectorTest.recordNetwork = function()
14 { 56 {
15 WebInspector.panels.network._networkLogView.setRecording(true); 57 WebInspector.panels.network._networkLogView.setRecording(true);
16 } 58 }
17 59
18 InspectorTest.networkRequests = function() 60 InspectorTest.networkRequests = function()
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (msg.messageText.indexOf("XHR loaded") !== -1) 100 if (msg.messageText.indexOf("XHR loaded") !== -1)
59 callback(); 101 callback();
60 else 102 else
61 InspectorTest.addConsoleSniffer(innerCallback); 103 InspectorTest.addConsoleSniffer(innerCallback);
62 } 104 }
63 105
64 InspectorTest.addConsoleSniffer(innerCallback); 106 InspectorTest.addConsoleSniffer(innerCallback);
65 InspectorTest.evaluateInPage("makeXHRForJSONArguments(\"" + jsonArgs + "\")" ); 107 InspectorTest.evaluateInPage("makeXHRForJSONArguments(\"" + jsonArgs + "\")" );
66 } 108 }
67 109
110 InspectorTest.makeFetch = function(url, requestInitializer, callback)
111 {
112 InspectorTest.invokePageFunctionAsync("makeFetch", url, requestInitializer, callback);
113 }
114
68 InspectorTest.HARPropertyFormatters = { 115 InspectorTest.HARPropertyFormatters = {
69 bodySize: "formatAsTypeName", 116 bodySize: "formatAsTypeName",
70 compression: "formatAsTypeName", 117 compression: "formatAsTypeName",
71 connection: "formatAsTypeName", 118 connection: "formatAsTypeName",
72 headers: "formatAsTypeName", 119 headers: "formatAsTypeName",
73 headersSize: "formatAsTypeName", 120 headersSize: "formatAsTypeName",
74 id: "formatAsTypeName", 121 id: "formatAsTypeName",
75 onContentLoad: "formatAsTypeName", 122 onContentLoad: "formatAsTypeName",
76 onLoad: "formatAsTypeName", 123 onLoad: "formatAsTypeName",
77 receive: "formatAsTypeName", 124 receive: "formatAsTypeName",
78 startedDateTime: "formatAsRecentTime", 125 startedDateTime: "formatAsRecentTime",
79 time: "formatAsTypeName", 126 time: "formatAsTypeName",
80 timings: "formatAsTypeName", 127 timings: "formatAsTypeName",
81 version: "formatAsTypeName", 128 version: "formatAsTypeName",
82 wait: "formatAsTypeName", 129 wait: "formatAsTypeName",
83 _transferSize: "formatAsTypeName", 130 _transferSize: "formatAsTypeName",
84 _error: "skip", 131 _error: "skip",
85 }; 132 };
86 133
87 // addObject checks own properties only, so make a deep copy rather than use pro totype. 134 // addObject checks own properties only, so make a deep copy rather than use pro totype.
88 InspectorTest.HARPropertyFormattersWithSize = JSON.parse(JSON.stringify(Inspecto rTest.HARPropertyFormatters)); 135 InspectorTest.HARPropertyFormattersWithSize = JSON.parse(JSON.stringify(Inspecto rTest.HARPropertyFormatters));
89 InspectorTest.HARPropertyFormattersWithSize.size = "formatAsTypeName"; 136 InspectorTest.HARPropertyFormattersWithSize.size = "formatAsTypeName";
90 137
91 }; 138 };
92
93 function makeSimpleXHR(method, url, async, callback)
94 {
95 makeSimpleXHRWithPayload(method, url, async, null, callback);
96 }
97
98 function makeSimpleXHRWithPayload(method, url, async, payload, callback)
99 {
100 makeXHR(method, url, async, undefined, undefined, [], false, payload, callba ck)
101 }
102
103 function makeXHR(method, url, async, user, password, headers, withCredentials, p ayload, type, callback)
104 {
105 var xhr = new XMLHttpRequest();
106 if (type == undefined)
107 xhr.responseType = "";
108 else
109 xhr.responseType = type;
110 xhr.onreadystatechange = function()
111 {
112 if (xhr.readyState === XMLHttpRequest.DONE) {
113 if (typeof(callback) === "function")
114 callback();
115 }
116 }
117 xhr.open(method, url, async, user, password);
118 xhr.withCredentials = withCredentials;
119 for (var i = 0; i < headers.length; ++i)
120 xhr.setRequestHeader(headers[i][0], headers[i][1]);
121 xhr.send(payload);
122 }
123
124 function makeXHRForJSONArguments(jsonArgs)
125 {
126 var args = JSON.parse(jsonArgs);
127 makeXHR(args.method, args.url, args.async, args.user, args.password, args.he aders || [], args.withCredentials, args.payload, args.type, xhrLoadedCallback);
128 }
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/inspector/inspector-test.js ('k') | LayoutTests/http/tests/inspector/network/network-eventsource.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698