| OLD | NEW |
| (Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script src="../inspector-protocol/inspector-protocol-test.js"></script> |
| 4 <script> |
| 5 |
| 6 async function test() { |
| 7 var requestWillBeSentPromise = InspectorTest.waitForEventPromise('Network.re
questWillBeSent'); |
| 8 // This url should be cross origin. |
| 9 const url = 'https://127.0.0.1:8443/inspector-protocol/resources/cors-data.p
hp'; |
| 10 |
| 11 await InspectorTest.sendCommandPromise("Network.enable", {}); |
| 12 InspectorTest.log("Network Enabled"); |
| 13 |
| 14 InspectorTest.evaluateInPage("xhr = new XMLHttpRequest();"); |
| 15 InspectorTest.evaluateInPage("xhr.open('GET', '" + url + "', true);"); |
| 16 InspectorTest.evaluateInPage("xhr.setRequestHeader('Authorization', '');"); |
| 17 InspectorTest.evaluateInPage("xhr.responseType = 'blob';"); |
| 18 InspectorTest.evaluateInPage("xhr.send();"); |
| 19 InspectorTest.log("Evaled fetch command in page"); |
| 20 |
| 21 var event = await requestWillBeSentPromise; |
| 22 InspectorTest.log("Request will be sent"); |
| 23 InspectorTest.log("Request Method (should be OPTIONS): " + event.params.requ
est.method); |
| 24 InspectorTest.log("Event URL has appropriate ending: " + event.params.reques
t.url.endsWith(url)); |
| 25 |
| 26 var event = await InspectorTest.waitForEventPromise('Network.requestWillBeSe
nt'); |
| 27 InspectorTest.log("Second Response Method (should be GET): " + event.params.
request.method); |
| 28 var requestId = event.params.requestId; |
| 29 |
| 30 |
| 31 var event = await InspectorTest.waitForEventPromise('Network.responseReceive
d'); |
| 32 InspectorTest.log("Got response received"); |
| 33 InspectorTest.log("requestId is the same as requestWillBeSent: " + (requestI
d === event.params.requestId)); |
| 34 |
| 35 var message = await InspectorTest.sendCommandPromise("Network.getResponseBod
y", {requestId: requestId}); |
| 36 InspectorTest.log("Response Body: " + message.result.body); |
| 37 |
| 38 InspectorTest.completeTest(); |
| 39 } |
| 40 </script> |
| 41 </head> |
| 42 <body onload="runTest()"> |
| 43 <p>Test to make sure if an xhr is fetched with the response as a blob and cross
origin devtools can get body.</p> |
| 44 </body> |
| 45 </html> |
| OLD | NEW |