Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1546)

Unified Diff: third_party/WebKit/LayoutTests/custom-elements/spec/resources/custom-elements-helpers.js

Issue 2443543002: createElement should not transmit exceptions but report them. (Closed)
Patch Set: Rebaseline tests. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/custom-elements/spec/resources/custom-elements-helpers.js
diff --git a/third_party/WebKit/LayoutTests/custom-elements/spec/resources/custom-elements-helpers.js b/third_party/WebKit/LayoutTests/custom-elements/spec/resources/custom-elements-helpers.js
index 14fd646a956ad04debaeaeebd55505f0317d006b..50fe9722bcf7216a69e1243fe57c666f01e4720d 100644
--- a/third_party/WebKit/LayoutTests/custom-elements/spec/resources/custom-elements-helpers.js
+++ b/third_party/WebKit/LayoutTests/custom-elements/spec/resources/custom-elements-helpers.js
@@ -48,3 +48,25 @@ function assert_is_upgraded(element, className, description) {
assert_true(element.matches(':defined'), description);
assert_equals(Object.getPrototypeOf(element), className.prototype, description);
}
+
+// Asserts that func synchronously invokes the error event handler in w
+// with the expected error.
+function assert_reports(w, expected_error, func, description) {
+ let old_onerror = w.onerror;
+ let errors = [];
+ w.onerror = (event, source, line_number, column_number, error) => {
+ errors.push(error);
+ return true; // the error is handled
+ };
+ try {
+ func();
+ } catch (e) {
+ assert_unreached(`should report, not throw, an exception: ${e}`);
+ } finally {
+ w.onerror = old_onerror;
+ }
+ assert_equals(1, errors.length);
+ // assert_throws has an error expectation matcher that can only be
+ // accessed by throwing the error
+ assert_throws(expected_error, () => { throw errors[0]; });
+}

Powered by Google App Engine
This is Rietveld 408576698