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 536d56cc2a89b6481ea475781bea779b336eb666..59df1e341825a80e6cdfd3bd8169ac9ec0a7a475 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.
 2017-12-19  Jer Noble  <jer.noble@apple.com>
 
         Playing media elements which call "pause(); play()" will have the play promise rejected.
index 821598275b5c352aa4f3f0bdc06faffcdad4e131..989003383d5b6a9acc5ca5c505c06582d8f536b6 100644 (file)
@@ -30,7 +30,12 @@ The following assertion is expected to fail.
 FAIL: Should produce an exception.
     Expected: not null
     Actual: null
 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 e7df6769aec4fb6fe953ff8fc702f5d43fb0800e..b0327eceaa676a1c75cd322ae18195a8087ba5a4 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>
     suite.runTestCasesAndFinish();
 }
 </script>
index 1b02d659a932fcd03267c3d422a731dda03cd88a..1ad3575b1239e4c478658e377ba85a1248c8229b 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
 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 cbfe88308758ae59fcd82fa2980aa9b2534afb4c..ff66acab7b7fae9197ac64c70b07224600f9043e 100644 (file)
@@ -218,7 +218,7 @@ TestHarness = class TestHarness extends WI.Object
                 return result.then((resolvedValue) => {
                     expectAndDumpError(null);
                     return Promise.reject(resolvedValue);
                 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);
                 });
                     expectAndDumpError(e);
                     return Promise.resolve(e);
                 });