Title: [206112] trunk/LayoutTests
Revision
206112
Author
commit-qu...@webkit.org
Date
2016-09-19 13:45:17 -0700 (Mon, 19 Sep 2016)

Log Message

Web Inspector: adopt Object.awaitEvent in LayoutTests/inspector/network
https://bugs.webkit.org/show_bug.cgi?id=162099

Patch by Devin Rousso <dcrousso+web...@gmail.com> on 2016-09-19
Reviewed by Brian Burg.

Replace instances of singleFireEventListener with awaitEvent and use promise logic to make
tests more readable.

* inspector/network/client-blocked-load-expected.txt:
* inspector/network/client-blocked-load.html:
* inspector/network/xhr-json-blob-has-content.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (206111 => 206112)


--- trunk/LayoutTests/ChangeLog	2016-09-19 20:41:28 UTC (rev 206111)
+++ trunk/LayoutTests/ChangeLog	2016-09-19 20:45:17 UTC (rev 206112)
@@ -1,5 +1,19 @@
 2016-09-19  Devin Rousso  <dcrousso+web...@gmail.com>
 
+        Web Inspector: adopt Object.awaitEvent in LayoutTests/inspector/network
+        https://bugs.webkit.org/show_bug.cgi?id=162099
+
+        Reviewed by Brian Burg.
+
+        Replace instances of singleFireEventListener with awaitEvent and use promise logic to make
+        tests more readable.
+
+        * inspector/network/client-blocked-load-expected.txt:
+        * inspector/network/client-blocked-load.html:
+        * inspector/network/xhr-json-blob-has-content.html:
+
+2016-09-19  Devin Rousso  <dcrousso+web...@gmail.com>
+
         Web Inspector: adopt Object.awaitEvent in LayoutTests/inspector/indexeddb
         https://bugs.webkit.org/show_bug.cgi?id=162073
 

Modified: trunk/LayoutTests/inspector/network/client-blocked-load-expected.txt (206111 => 206112)


--- trunk/LayoutTests/inspector/network/client-blocked-load-expected.txt	2016-09-19 20:41:28 UTC (rev 206111)
+++ trunk/LayoutTests/inspector/network/client-blocked-load-expected.txt	2016-09-19 20:45:17 UTC (rev 206112)
@@ -4,6 +4,6 @@
 == Running test suite: ClientBlockedResourceLoad
 -- Running test case: TriggerBlockedResourceLoad
 PASS: Resource should be created.
+PASS: Added Resource load did fail.
 PASS: Request url should be rewritten to the null string.
-PASS: Resource load should fail.
 

Modified: trunk/LayoutTests/inspector/network/client-blocked-load.html (206111 => 206112)


--- trunk/LayoutTests/inspector/network/client-blocked-load.html	2016-09-19 20:41:28 UTC (rev 206111)
+++ trunk/LayoutTests/inspector/network/client-blocked-load.html	2016-09-19 20:45:17 UTC (rev 206112)
@@ -18,17 +18,20 @@
     suite.addTestCase({
         name: "TriggerBlockedResourceLoad",
         description: "Trigger a blocked resource load and ensure we get notified of the request.",
-        test: (resolve, reject) => {
-            InspectorTest.evaluateInPage("createBlockedResourceLoad()");
-            WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {
-                let resource = event.data.resource;
+        test(resolve, reject) {
+            Promise.all([
+                WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded),
+                WebInspector.Resource.awaitEvent(WebInspector.Resource.Event.LoadingDidFail)
+            ])
+            .then(([resourceWasAddedEvent, loadingDidFailEvent]) => {
+                let resource = resourceWasAddedEvent.data.resource;
                 InspectorTest.expectThat(resource instanceof WebInspector.Resource, "Resource should be created.");
+                InspectorTest.expectThat(resource === loadingDidFailEvent.target, "Added Resource load did fail.");
                 InspectorTest.expectThat(resource.url ="" "", "Request url should be rewritten to the null string.");
-                resource.singleFireEventListener(WebInspector.Resource.Event.LoadingDidFail, (event) => {
-                    InspectorTest.pass("Resource load should fail.");
-                    resolve();
-                });
-            });
+            })
+            .then(resolve, reject);
+
+            InspectorTest.evaluateInPage("createBlockedResourceLoad()");
         }
     });
 

Modified: trunk/LayoutTests/inspector/network/xhr-json-blob-has-content.html (206111 => 206112)


--- trunk/LayoutTests/inspector/network/xhr-json-blob-has-content.html	2016-09-19 20:41:28 UTC (rev 206111)
+++ trunk/LayoutTests/inspector/network/xhr-json-blob-has-content.html	2016-09-19 20:45:17 UTC (rev 206112)
@@ -25,18 +25,25 @@
     suite.addTestCase({
         name: "XHR.JSONContent",
         description: "Ensure an XMLHttpRequest with JSON content still gives us text.",
-        test: (resolve, reject) => {
+        test(resolve, reject) {
+            let resource = null;
+
+            WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded)
+            .then((event) => {
+                resource = event.data.resource;
+                InspectorTest.expectThat(resource instanceof WebInspector.Resource, "Resource should be created.");
+                return resource.awaitEvent(WebInspector.Resource.Event.LoadingDidFinish);
+            })
+            .then((event) => {
+                InspectorTest.pass("Resource should complete loading.");
+                return resource.requestContent();
+            })
+            .then((resource) => {
+                InspectorTest.expectThat(resource.content === jsonContent, "Resource has expected content.");
+            })
+            .then(resolve, reject);
+
             InspectorTest.evaluateInPage("createJSONXHR()");
-            WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {
-                let resource = event.data.resource;
-                InspectorTest.expectThat(resource instanceof WebInspector.Resource, "Resource should be created.");
-                resource.singleFireEventListener(WebInspector.Resource.Event.LoadingDidFinish, (event) => {
-                    InspectorTest.pass("Resource should complete loading.");
-                    resource.requestContent().then(() => {
-                        InspectorTest.expectThat(resource.content === jsonContent, "Resource has expected content.");
-                    }).then(resolve, reject);
-                });
-            });
         }
     });
 
@@ -43,18 +50,25 @@
     suite.addTestCase({
         name: "XHR.JSONContent.Blob",
         description: "Ensure an XMLHttpRequest with JSON content and a responseType of blob still gives us text.",
-        test: (resolve, reject) => {
+        test(resolve, reject) {
+            let resource = null;
+
+            WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded)
+            .then((event) => {
+                resource = event.data.resource;
+                InspectorTest.expectThat(resource instanceof WebInspector.Resource, "Resource should be created.");
+                return resource.awaitEvent(WebInspector.Resource.Event.LoadingDidFinish);
+            })
+            .then((event) => {
+                InspectorTest.pass("Resource should complete loading.");
+                return resource.requestContent();
+            })
+            .then((resource) => {
+                InspectorTest.expectThat(resource.content === jsonContent, "Resource has expected content.");
+            })
+            .then(resolve, reject);
+
             InspectorTest.evaluateInPage("createJSONBlobXHR()");
-            WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {
-                let resource = event.data.resource;
-                InspectorTest.expectThat(resource instanceof WebInspector.Resource, "Resource should be created.");
-                resource.singleFireEventListener(WebInspector.Resource.Event.LoadingDidFinish, (event) => {
-                    InspectorTest.pass("Resource should complete loading.");
-                    resource.requestContent().then(() => {
-                        InspectorTest.expectThat(resource.content === jsonContent, "Resource has expected content.");
-                    }).then(resolve, reject);
-                });
-            });
         }
     });
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to