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

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

Issue 1362953003: Fire window.onerror for uncaught IndexedDB errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 3 years, 11 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 | third_party/WebKit/LayoutTests/storage/indexeddb/error-attributes.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/resources/js-test.js
diff --git a/third_party/WebKit/LayoutTests/resources/js-test.js b/third_party/WebKit/LayoutTests/resources/js-test.js
index 77b85c369afad00928e5247f88baeb045c307412..7685db1f00882ee40a1ef4de886f319f4b68bb2e 100644
--- a/third_party/WebKit/LayoutTests/resources/js-test.js
+++ b/third_party/WebKit/LayoutTests/resources/js-test.js
@@ -16,7 +16,7 @@ var isJsTest = true;
var description, debug, successfullyParsed, getOrCreateTestElement;
-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
@@ -119,7 +119,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) {
@@ -715,7 +716,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;
}
@@ -741,6 +742,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 | third_party/WebKit/LayoutTests/storage/indexeddb/error-attributes.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698