зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1389913 - IDB should not propagate the error events to self.onerror, r=bevis
This commit is contained in:
Родитель
f3601e8230
Коммит
e796e759ca
|
@ -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<bool> gClosed(false);
|
|||
Atomic<bool> gTestingMode(false);
|
||||
Atomic<bool> gExperimentalFeaturesEnabled(false);
|
||||
Atomic<bool> gFileHandleEnabled(false);
|
||||
Atomic<bool> gPrefErrorEventToSelfError(false);
|
||||
Atomic<int32_t> gDataThresholdBytes(0);
|
||||
Atomic<int32_t> 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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[idbfactory_open10.htm]
|
||||
type: testharness
|
||||
expected: ERROR
|
|
@ -1,6 +1,5 @@
|
|||
[idbfactory_open9.htm]
|
||||
type: testharness
|
||||
expected: ERROR
|
||||
[Calling open() with version argument undefined should throw TypeError.]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[idbrequest-onupgradeneeded.htm]
|
||||
type: testharness
|
||||
expected: ERROR
|
|
@ -1,3 +0,0 @@
|
|||
[idbtransaction_objectStoreNames.html]
|
||||
type: testharness
|
||||
expected: ERROR
|
|
@ -1,3 +0,0 @@
|
|||
[upgrade-transaction-lifecycle-backend-aborted.html]
|
||||
type: testharness
|
||||
expected: ERROR
|
|
@ -1,3 +0,0 @@
|
|||
[domstringlist.html]
|
||||
type: testharness
|
||||
expected: ERROR
|
Загрузка…
Ссылка в новой задаче