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

Unified Diff: LayoutTests/resources/js-test.js

Issue 243523003: Fire window.onerror for uncaught IndexedDB errors (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased and linkage fix Created 5 years, 3 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
« no previous file with comments | « no previous file | LayoutTests/storage/indexeddb/delete-in-upgradeneeded-close-in-versionchange-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/resources/js-test.js
diff --git a/LayoutTests/resources/js-test.js b/LayoutTests/resources/js-test.js
index ba1d8acddd5a9f64898389d1ea286d6425746baf..781f378f2309a4dadce2489b07487c14e3980ea7 100644
--- a/LayoutTests/resources/js-test.js
+++ b/LayoutTests/resources/js-test.js
@@ -15,7 +15,7 @@ var isJsTest = true;
var description, debug, successfullyParsed;
-var expectingError; // set by shouldHaveError()
+var expectingError; // set by expectError()
var expectedErrorMessage; // set by onerror when expectingError is true
var unexpectedErrorMessage; // set by onerror when expectingError is not true
@@ -112,7 +112,8 @@ var unexpectedErrorMessage; // set by onerror when expectingError is not true
if (self.expectingError) {
self.expectedErrorMessage = message;
self.expectingError = false;
- return;
+ // In workers, consume expected error so window doesn't fail the test.
+ return isWorker();
}
self.unexpectedErrorMessage = message;
if (self.jsTestIsAsync) {
@@ -706,7 +707,7 @@ function shouldBeNow(a, delta)
function expectError()
{
if (expectingError) {
- testFailed("shouldHaveError() called twice before an error occurred!");
+ testFailed("expectError() called twice before an error occurred!");
}
expectingError = true;
}
@@ -732,6 +733,22 @@ function shouldHaveHadError(message)
testFailed("expectError() not called before shouldHaveHadError()");
}
+// Waits for the global 'onerror' handler to fire, verifies the
+// message with a regex, then calls another function. e.g.
+// waitForError(/AbortError/, nextTestCase);
+function waitForError(regex, continuation)
+{
+ var original_onerror = self.onerror;
+ self.onerror = function(message) {
+ self.onerror = original_onerror;
+ if (regex.test(message))
+ testPassed("Got expected error: '" + message + "'");
+ else
+ testFailed("Unexpected error '" + message + "', expected: " + String(regex));
+ continuation();
+ };
+}
+
// With Oilpan tests that rely on garbage collection need to go through
// the event loop in order to get precise garbage collections. Oilpan
// uses conservative stack scanning when not at the event loop and that
« no previous file with comments | « no previous file | LayoutTests/storage/indexeddb/delete-in-upgradeneeded-close-in-versionchange-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698