Web Inspector: add InspectorTest.expectException() and use it
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Dec 2017 23:10:00 +0000 (23:10 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Dec 2017 23:10:00 +0000 (23:10 +0000)
commite08e8390cafc83b9b0f5d7f713455eea0173aa79
treecf0841e73e7c6386dc654421fdf61c4178f2bf10
parent384e476d55a43d740959943498d06de3e1661e52
Web Inspector: add InspectorTest.expectException() and use it
https://bugs.webkit.org/show_bug.cgi?id=180719

Reviewed by Matt Baker.

Source/WebInspectorUI:

This helps straighten out async test() functions that need
to test exceptional cases. Without this, every such method
needs try/catch boilerplate to leak the error outside the
scope of the catch-block and then assert that it exists.

* UserInterface/Test/TestHarness.js:
(TestHarness.prototype.expectException):
Added. This method takes a callback which is expected to raise
an exception either by throwing an Error instance or returning
a Promise that rejects with an Error instance. The method returns
a Promise that is either resolved with the expected exception
from one of the above sources, or is rejected with the non-exception
result that was returned or resolved by the callback.

LayoutTests:

* inspector/dom/highlightNode-expected.txt:
* inspector/dom/highlightNode.html:
Adopt the new helper method.

* inspector/unit-tests/test-harness-expect-functions-async-expected.txt: Added.
* inspector/unit-tests/test-harness-expect-functions-async.html: Added.
Add a separate async test suite for async expect* functions.

* inspector/unit-tests/test-harness-expect-functions-expected.txt:
* inspector/unit-tests/test-harness-expect-functions.html:
Standardize the naming for these two suites.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225810 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/inspector/dom/highlightNode-expected.txt
LayoutTests/inspector/dom/highlightNode.html
LayoutTests/inspector/unit-tests/test-harness-expect-functions-async-expected.txt [new file with mode: 0644]
LayoutTests/inspector/unit-tests/test-harness-expect-functions-async.html [new file with mode: 0644]
LayoutTests/inspector/unit-tests/test-harness-expect-functions-expected.txt
LayoutTests/inspector/unit-tests/test-harness-expect-functions.html
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Test/TestHarness.js