Web Inspector: InspectorTest.expectException does not handle implicitly resolved...
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Dec 2017 23:53:02 +0000 (23:53 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Dec 2017 23:53:02 +0000 (23:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180944

Reviewed by Joseph Pecoraro.

Source/WebInspectorUI:

* UserInterface/Test/TestHarness.js:
(TestHarness.prototype.expectException):
Don't chain .catch after we might have just returned a rejected promise.

LayoutTests:

Add a new test case for implicitly resolved async functions passed to expectException.
Rebaseline one existing test that had a failing assertion that progresses with
this change. I didn't notice it because the assertion just prior is expected to fail.

* inspector/unit-tests/test-harness-expect-functions-async-expected.txt:
* inspector/unit-tests/test-harness-expect-functions-async.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226153 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/unit-tests/test-harness-expect-functions-async-expected.txt
LayoutTests/inspector/unit-tests/test-harness-expect-functions-async.html
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Test/TestHarness.js

index 536d56c..59df1e3 100644 (file)
@@ -1,3 +1,17 @@
+2017-12-19  Brian Burg  <bburg@apple.com>
+
+        Web Inspector: InspectorTest.expectException does not handle implicitly resolved async functions correctly
+        https://bugs.webkit.org/show_bug.cgi?id=180944
+
+        Reviewed by Joseph Pecoraro.
+
+        Add a new test case for implicitly resolved async functions passed to expectException.
+        Rebaseline one existing test that had a failing assertion that progresses with
+        this change. I didn't notice it because the assertion just prior is expected to fail.
+
+        * inspector/unit-tests/test-harness-expect-functions-async-expected.txt:
+        * inspector/unit-tests/test-harness-expect-functions-async.html:
+
 2017-12-19  Jer Noble  <jer.noble@apple.com>
 
         Playing media elements which call "pause(); play()" will have the play promise rejected.
index 8215982..9890033 100644 (file)
@@ -30,7 +30,12 @@ The following assertion is expected to fail.
 FAIL: Should produce an exception.
     Expected: not null
     Actual: null
-PASS: Should produce an exception.
-42
-FAIL: The returned promise should not resolve since an expected exception was not raised.
+PASS: Rejected value should be the returned value.
+
+-- Running test case: expectException.AsyncWorkThatResolvesImplicitly
+The following assertion is expected to fail.
+FAIL: Should produce an exception.
+    Expected: not null
+    Actual: null
+PASS: Implicitly resolved value should be undefined.
 
index e7df676..b0327ec 100644 (file)
@@ -80,6 +80,22 @@ function test()
         }
     });
 
+    suite.addTestCase({
+        name: "expectException.AsyncWorkThatResolvesImplicitly",
+        async test() {
+            InspectorTest.log("The following assertion is expected to fail.");
+
+            let returnValue = 42;
+            await InspectorTest.expectException(async () => {
+                1 + 1;
+            }).then(() => {
+                InspectorTest.fail("The returned promise should not resolve since an expected exception was not raised.");
+            }).catch((resolvedValue) => {
+                InspectorTest.expectEqual(resolvedValue, undefined, "Implicitly resolved value should be undefined.");
+            });
+        }
+    });
+
     suite.runTestCasesAndFinish();
 }
 </script>
index 1b02d65..1ad3575 100644 (file)
@@ -1,3 +1,14 @@
+2017-12-19  Brian Burg  <bburg@apple.com>
+
+        Web Inspector: InspectorTest.expectException does not handle implicitly resolved async functions correctly
+        https://bugs.webkit.org/show_bug.cgi?id=180944
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Test/TestHarness.js:
+        (TestHarness.prototype.expectException):
+        Don't chain .catch after we might have just returned a rejected promise.
+
 2017-12-19  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Network Table - Update the Time column to include the total duration not just the download duration
index cbfe883..ff66aca 100644 (file)
@@ -218,7 +218,7 @@ TestHarness = class TestHarness extends WI.Object
                 return result.then((resolvedValue) => {
                     expectAndDumpError(null);
                     return Promise.reject(resolvedValue);
-                }).catch((e) => {
+                }, (e) => { // Don't chain the .catch as it will log the value we just rejected.
                     expectAndDumpError(e);
                     return Promise.resolve(e);
                 });