From e796e759ca1a526a0aa4575436ea765bfdc559df Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Wed, 27 Sep 2017 10:20:24 +0200 Subject: [PATCH] Bug 1389913 - IDB should not propagate the error events to self.onerror, r=bevis --- dom/indexedDB/IndexedDatabaseManager.cpp | 12 ++++++++++ .../test/event_propagation_iframe.html | 22 ++++--------------- .../test/unit/test_transaction_error.js | 17 -------------- .../meta/IndexedDB/idbfactory_open10.htm.ini | 3 --- .../meta/IndexedDB/idbfactory_open9.htm.ini | 1 - .../idbrequest-onupgradeneeded.htm.ini | 3 --- .../idbtransaction_objectStoreNames.html.ini | 3 --- ...saction-lifecycle-backend-aborted.html.ini | 3 --- .../collections/domstringlist.html.ini | 3 --- 9 files changed, 16 insertions(+), 51 deletions(-) delete mode 100644 testing/web-platform/meta/IndexedDB/idbfactory_open10.htm.ini delete mode 100644 testing/web-platform/meta/IndexedDB/idbrequest-onupgradeneeded.htm.ini delete mode 100644 testing/web-platform/meta/IndexedDB/idbtransaction_objectStoreNames.html.ini delete mode 100644 testing/web-platform/meta/IndexedDB/upgrade-transaction-lifecycle-backend-aborted.html.ini delete mode 100644 testing/web-platform/meta/html/infrastructure/common-dom-interfaces/collections/domstringlist.html.ini diff --git a/dom/indexedDB/IndexedDatabaseManager.cpp b/dom/indexedDB/IndexedDatabaseManager.cpp index d74881d7a407..8834339e2493 100644 --- a/dom/indexedDB/IndexedDatabaseManager.cpp +++ b/dom/indexedDB/IndexedDatabaseManager.cpp @@ -146,6 +146,7 @@ const char kPrefExperimental[] = IDB_PREF_BRANCH_ROOT "experimental"; const char kPrefFileHandle[] = "dom.fileHandle.enabled"; const char kDataThresholdPref[] = IDB_PREF_BRANCH_ROOT "dataThreshold"; const char kPrefMaxSerilizedMsgSize[] = IDB_PREF_BRANCH_ROOT "maxSerializedMsgSize"; +const char kPrefErrorEventToSelfError[] = IDB_PREF_BRANCH_ROOT "errorEventToSelfError"; #define IDB_PREF_LOGGING_BRANCH_ROOT IDB_PREF_BRANCH_ROOT "logging." @@ -167,6 +168,7 @@ Atomic gClosed(false); Atomic gTestingMode(false); Atomic gExperimentalFeaturesEnabled(false); Atomic gFileHandleEnabled(false); +Atomic gPrefErrorEventToSelfError(false); Atomic gDataThresholdBytes(0); Atomic gMaxSerializedMsgSize(0); @@ -403,6 +405,9 @@ IndexedDatabaseManager::Init() Preferences::RegisterCallbackAndCall(AtomicBoolPrefChangedCallback, kPrefFileHandle, &gFileHandleEnabled); + Preferences::RegisterCallbackAndCall(AtomicBoolPrefChangedCallback, + kPrefErrorEventToSelfError, + &gPrefErrorEventToSelfError); // By default IndexedDB uses SQLite with PRAGMA synchronous = NORMAL. This // guarantees (unlike synchronous = OFF) atomicity and consistency, but not @@ -475,6 +480,9 @@ IndexedDatabaseManager::Destroy() Preferences::UnregisterCallback(AtomicBoolPrefChangedCallback, kPrefFileHandle, &gFileHandleEnabled); + Preferences::UnregisterCallback(AtomicBoolPrefChangedCallback, + kPrefErrorEventToSelfError, + &gPrefErrorEventToSelfError); Preferences::UnregisterCallback(LoggingModePrefChangedCallback, kPrefLoggingDetails); @@ -502,6 +510,10 @@ IndexedDatabaseManager::CommonPostHandleEvent(EventChainPostVisitor& aVisitor, MOZ_ASSERT(aVisitor.mDOMEvent); MOZ_ASSERT(aFactory); + if (!gPrefErrorEventToSelfError) { + return NS_OK; + } + if (aVisitor.mEventStatus == nsEventStatus_eConsumeNoDefault) { return NS_OK; } diff --git a/dom/indexedDB/test/event_propagation_iframe.html b/dom/indexedDB/test/event_propagation_iframe.html index 2c89aac8e992..fe7cce26c9ce 100644 --- a/dom/indexedDB/test/event_propagation_iframe.html +++ b/dom/indexedDB/test/event_propagation_iframe.html @@ -26,14 +26,8 @@ } function finishTest() { - // Let window.onerror have a chance to fire - setTimeout(function() { - setTimeout(function() { - testGenerator.return(); - ok(windowErrorCount == 1, "Good window.onerror count"); - window.parent.postMessage("SimpleTest.finish();", "*"); - }, 0); - }, 0); + testGenerator.return(); + window.parent.postMessage("SimpleTest.finish();", "*"); } const eventChain = [ @@ -45,12 +39,6 @@ let captureCount = 0; let bubbleCount = 0; let atTargetCount = 0; - let windowErrorCount = 0; - - window.onerror = function(event) { - ok(!windowErrorCount++, "Correct number of window.onerror events"); - setTimeout(function() { testGenerator.next(); }, 0); - }; function errorEventCounter(event) { ok(event.type == "error", "Got an error event"); @@ -67,7 +55,7 @@ } else if (event.eventPhase == event.BUBBLING_PHASE) { constructor = eventChain[++bubbleCount]; - if (windowErrorCount && bubbleCount == eventChain.length - 1) { + if (bubbleCount == eventChain.length - 1) { event.preventDefault(); } } @@ -80,9 +68,7 @@ ok(atTargetCount == 1, "Got one atTarget event"); captureCount = bubbleCount = atTargetCount = 0; - if (windowErrorCount) { - finishTest(); - } + finishTest(); } } diff --git a/dom/indexedDB/test/unit/test_transaction_error.js b/dom/indexedDB/test/unit/test_transaction_error.js index 441765a4ac87..18eab8114b41 100644 --- a/dom/indexedDB/test/unit/test_transaction_error.js +++ b/dom/indexedDB/test/unit/test_transaction_error.js @@ -88,23 +88,6 @@ function* testSteps() { info("Adding duplicate entry without preventDefault()"); - if ("SimpleTest" in this) { - /* global SimpleTest */ - SimpleTest.expectUncaughtException(); - } else if ("DedicatedWorkerGlobalScope" in self && - self instanceof DedicatedWorkerGlobalScope) { - let oldErrorFunction = self.onerror; - self.onerror = function(message, file, line) { - self.onerror = oldErrorFunction; - oldErrorFunction = null; - - is(message, - "ConstraintError", - "Got expected ConstraintError on DedicatedWorkerGlobalScope"); - return true; - }; - } - request = objectStore.add(data, dataKey); request.onsuccess = unexpectedSuccessHandler; request.onerror = grabEventAndContinueHandler; diff --git a/testing/web-platform/meta/IndexedDB/idbfactory_open10.htm.ini b/testing/web-platform/meta/IndexedDB/idbfactory_open10.htm.ini deleted file mode 100644 index 176801a9a2b4..000000000000 --- a/testing/web-platform/meta/IndexedDB/idbfactory_open10.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[idbfactory_open10.htm] - type: testharness - expected: ERROR diff --git a/testing/web-platform/meta/IndexedDB/idbfactory_open9.htm.ini b/testing/web-platform/meta/IndexedDB/idbfactory_open9.htm.ini index 75e5d9b56ee7..2ee152bf311a 100644 --- a/testing/web-platform/meta/IndexedDB/idbfactory_open9.htm.ini +++ b/testing/web-platform/meta/IndexedDB/idbfactory_open9.htm.ini @@ -1,6 +1,5 @@ [idbfactory_open9.htm] type: testharness - expected: ERROR [Calling open() with version argument undefined should throw TypeError.] expected: FAIL diff --git a/testing/web-platform/meta/IndexedDB/idbrequest-onupgradeneeded.htm.ini b/testing/web-platform/meta/IndexedDB/idbrequest-onupgradeneeded.htm.ini deleted file mode 100644 index d6b41b441461..000000000000 --- a/testing/web-platform/meta/IndexedDB/idbrequest-onupgradeneeded.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[idbrequest-onupgradeneeded.htm] - type: testharness - expected: ERROR diff --git a/testing/web-platform/meta/IndexedDB/idbtransaction_objectStoreNames.html.ini b/testing/web-platform/meta/IndexedDB/idbtransaction_objectStoreNames.html.ini deleted file mode 100644 index cc07c7db2eaa..000000000000 --- a/testing/web-platform/meta/IndexedDB/idbtransaction_objectStoreNames.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[idbtransaction_objectStoreNames.html] - type: testharness - expected: ERROR diff --git a/testing/web-platform/meta/IndexedDB/upgrade-transaction-lifecycle-backend-aborted.html.ini b/testing/web-platform/meta/IndexedDB/upgrade-transaction-lifecycle-backend-aborted.html.ini deleted file mode 100644 index 6101fd438020..000000000000 --- a/testing/web-platform/meta/IndexedDB/upgrade-transaction-lifecycle-backend-aborted.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[upgrade-transaction-lifecycle-backend-aborted.html] - type: testharness - expected: ERROR diff --git a/testing/web-platform/meta/html/infrastructure/common-dom-interfaces/collections/domstringlist.html.ini b/testing/web-platform/meta/html/infrastructure/common-dom-interfaces/collections/domstringlist.html.ini deleted file mode 100644 index d3c403c02bd4..000000000000 --- a/testing/web-platform/meta/html/infrastructure/common-dom-interfaces/collections/domstringlist.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[domstringlist.html] - type: testharness - expected: ERROR