[Fetch API] Response should keep all ResourceResponse information
[WebKit-https.git] / LayoutTests / http / tests / inspector / network / fetch-network-data.html
index f48b6d13ea04c69132780004511e3168b49f2f9b..5982409cb290ee725b6056ff93e737d722d6c19e 100644 (file)
@@ -12,22 +12,22 @@ function test()
         suite.addTestCase({
             name, test(resolve, reject) {
                 InspectorTest.evaluateInPage(expression);
-                WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {
+                WI.Frame.singleFireEventListener(WI.Frame.Event.ResourceWasAdded, (event) => {
                     let resource = event.data.resource;
-                    InspectorTest.expectEqual(resource.type, WebInspector.Resource.Type.Fetch, "Resource should be Fetch type.");
+                    InspectorTest.expectEqual(resource.type, WI.Resource.Type.Fetch, "Resource should be Fetch type.");
                     if (loadedHandler) {
-                        resource.awaitEvent(WebInspector.Resource.Event.LoadingDidFinish)
+                        resource.awaitEvent(WI.Resource.Event.LoadingDidFinish)
                             .then(() => { InspectorTest.pass("Resource should have loaded successfully.") })
                             .then(() => { loadedHandler(resource); })
                             .then(resolve, reject);
-                        resource.awaitEvent(WebInspector.Resource.Event.LoadingDidFail)
+                        resource.awaitEvent(WI.Resource.Event.LoadingDidFail)
                             .then(() => { InspectorTest.fail("Resource should not have failed to load.") })
                             .then(reject, reject);
                     } else if (failedHandler) {
-                        resource.awaitEvent(WebInspector.Resource.Event.LoadingDidFinish)
+                        resource.awaitEvent(WI.Resource.Event.LoadingDidFinish)
                             .then(() => { InspectorTest.fail("Resource should not have loaded successfully.") })
                             .then(resolve, reject);
-                        resource.awaitEvent(WebInspector.Resource.Event.LoadingDidFail)
+                        resource.awaitEvent(WI.Resource.Event.LoadingDidFail)
                             .then(() => { InspectorTest.pass("Resource should have failed to load.") })
                             .then(() => { failedHandler(resource); })
                             .then(resolve, reject);
@@ -52,9 +52,10 @@ function test()
         name: "Network.Fetch.ModeNoCORS.CrossOrigin",
         description: "Same Origin 'no-cors' fetch => type 'opaque'. Produces an opaque failure.",
         expression: `fetch("http://localhost:8000/inspector/network/resources/cors-data.pl", {mode: "no-cors"})`,
-        failedHandler(resource) {
-            InspectorTest.expectThat(resource.failed, "Load should have failed.");
-            InspectorTest.expectThat(resource.canceled, "Load should have canceled.");
+        loadedHandler(resource) {
+            InspectorTest.expectEqual(resource.mimeType, "application/json", "MIMEType should be 'application/json'.");
+            InspectorTest.expectEqual(resource.statusCode, 200, "Status code should be 200.");
+            InspectorTest.expectEqual(resource.responseHeaders["X-Custom-Header"], "Custom-Header-Value", "Should be able to see X-Custom-Header.");
         }
     });