Bug 823371 - Fire "blocked" event if deleteDatabase is blocked by other open connection. r=khuey

This commit is contained in:
Bevis Tseng 2016-05-11 16:36:52 +08:00
Родитель 942872afd3
Коммит 72c8e58003
7 изменённых файлов: 214 добавлений и 1 удалений

Просмотреть файл

@ -22228,7 +22228,7 @@ DeleteDatabaseOp::SendBlockedNotification()
MOZ_ASSERT(mState == State::WaitingForOtherDatabasesToClose);
if (!IsActorDestroyed()) {
Unused << SendBlocked(0);
Unused << SendBlocked(mPreviousVersion);
}
}

Просмотреть файл

@ -38,6 +38,8 @@ support-files =
unit/test_cursors.js
unit/test_deleteDatabase.js
unit/test_deleteDatabase_interactions.js
unit/test_deleteDatabase_onblocked.js
unit/test_deleteDatabase_onblocked_duringVersionChange.js
unit/test_event_source.js
unit/test_filehandle_append_read_data.js
unit/test_getAll.js
@ -171,6 +173,10 @@ skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
[test_deleteDatabase_interactions.html]
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
[test_deleteDatabase_onblocked.html]
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
[test_deleteDatabase_onblocked_duringVersionChange.html]
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
[test_error_events_abort_transactions.html]
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
[test_event_propagation.html]

Просмотреть файл

@ -0,0 +1,19 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html>
<head>
<title>Indexed Database Onblocked Test During Deleting Database</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="text/javascript;version=1.7" src="unit/test_deleteDatabase_onblocked.js"></script>
<script type="text/javascript;version=1.7" src="helpers.js"></script>
</head>
<body onload="runTest();"></body>
</html>

Просмотреть файл

@ -0,0 +1,19 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html>
<head>
<title>Indexed Database Onblocked Test During Version Change Transaction</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="text/javascript;version=1.7" src="unit/test_deleteDatabase_onblocked_duringVersionChange.js"></script>
<script type="text/javascript;version=1.7" src="helpers.js"></script>
</head>
<body onload="runTest();"></body>
</html>

Просмотреть файл

@ -0,0 +1,83 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
var testGenerator = testSteps();
function testSteps()
{
const name = this.window ? window.location.pathname : "Splendid Test";
const dbVersion = 10;
let openRequest = indexedDB.open(name, dbVersion);
openRequest.onerror = errorHandler;
openRequest.onblocked = errorHandler;
openRequest.onsuccess = unexpectedSuccessHandler;
openRequest.onupgradeneeded = grabEventAndContinueHandler;
let event = yield undefined;
is(event.type, "upgradeneeded", "Expect an upgradeneeded event");
ok(event instanceof IDBVersionChangeEvent, "Expect a versionchange event");
let db = event.target.result;
db.onversionchange = errorHandler;
db.createObjectStore("stuff");
openRequest.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
is(event.type, "success", "Expect a success event");
is(event.target, openRequest, "Event has right target");
ok(event.target.result instanceof IDBDatabase, "Result should be a database");
is(db.objectStoreNames.length, 1, "Expect an objectStore here");
db.onversionchange = grabEventAndContinueHandler;
let deletingRequest = indexedDB.deleteDatabase(name);
deletingRequest.onerror = errorHandler;
deletingRequest.onsuccess = errorHandler;
deletingRequest.onblocked = errorHandler;
event = yield undefined;
is(event.type, "versionchange", "Expect an versionchange event");
is(event.target, db, "Event has right target");
ok(event instanceof IDBVersionChangeEvent, "Expect a versionchange event");
is(event.oldVersion, dbVersion, "Correct old version");
is(event.newVersion, null, "Correct new version");
deletingRequest.onblocked = grabEventAndContinueHandler;
event = yield undefined;
is(event.type, "blocked", "Expect an blocked event");
is(event.target, deletingRequest, "Event has right target");
ok(event instanceof IDBVersionChangeEvent, "Expect a versionchange event");
is(event.oldVersion, dbVersion, "Correct old version");
is(event.newVersion, null, "Correct new version");
deletingRequest.onsuccess = grabEventAndContinueHandler;
db.close();
event = yield undefined;
is(event.type, "success", "expect a success event");
is(event.target, deletingRequest, "event has right target");
is(event.target.result, undefined, "event should have no result");
openRequest = indexedDB.open(name, 1);
openRequest.onerror = errorHandler;
openRequest.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
db = event.target.result;
is(db.version, 1, "DB has proper version");
is(db.objectStoreNames.length, 0, "DB should have no object stores");
db.close();
finishTest();
yield undefined;
}

Просмотреть файл

@ -0,0 +1,84 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
var testGenerator = testSteps();
function testSteps()
{
const name = this.window ? window.location.pathname : "Splendid Test";
const dbVersion = 10;
let openRequest = indexedDB.open(name, dbVersion);
openRequest.onerror = errorHandler;
openRequest.onblocked = errorHandler;
openRequest.onsuccess = unexpectedSuccessHandler;
openRequest.onupgradeneeded = grabEventAndContinueHandler;
let event = yield undefined;
is(event.type, "upgradeneeded", "Expect an upgradeneeded event");
ok(event instanceof IDBVersionChangeEvent, "Expect a versionchange event");
let db = event.target.result;
db.onversionchange = errorHandler;
db.createObjectStore("stuff");
let deletingRequest = indexedDB.deleteDatabase(name);
deletingRequest.onerror = errorHandler;
deletingRequest.onsuccess = errorHandler;
deletingRequest.onblocked = errorHandler;
openRequest.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
is(event.type, "success", "Expect a success event");
is(event.target, openRequest, "Event has right target");
ok(event.target.result instanceof IDBDatabase, "Result should be a database");
is(db.objectStoreNames.length, 1, "Expect an objectStore here");
db.onversionchange = grabEventAndContinueHandler;
event = yield undefined;
is(event.type, "versionchange", "Expect an versionchange event");
is(event.target, db, "Event has right target");
ok(event instanceof IDBVersionChangeEvent, "Expect a versionchange event");
is(event.oldVersion, dbVersion, "Correct old version");
is(event.newVersion, null, "Correct new version");
deletingRequest.onblocked = grabEventAndContinueHandler;
event = yield undefined;
is(event.type, "blocked", "Expect an blocked event");
is(event.target, deletingRequest, "Event has right target");
ok(event instanceof IDBVersionChangeEvent, "Expect a versionchange event");
is(event.oldVersion, dbVersion, "Correct old version");
is(event.newVersion, null, "Correct new version");
deletingRequest.onsuccess = grabEventAndContinueHandler;
db.close();
event = yield undefined;
is(event.type, "success", "expect a success event");
is(event.target, deletingRequest, "event has right target");
is(event.target.result, undefined, "event should have no result");
openRequest = indexedDB.open(name, 1);
openRequest.onerror = errorHandler;
openRequest.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
db = event.target.result;
is(db.version, 1, "DB has proper version");
is(db.objectStoreNames.length, 0, "DB should have no object stores");
db.close();
finishTest();
yield undefined;
}

Просмотреть файл

@ -22,6 +22,8 @@ skip-if = toolkit == 'android' # bug 864843
[test_cursors.js]
[test_deleteDatabase.js]
[test_deleteDatabase_interactions.js]
[test_deleteDatabase_onblocked.js]
[test_deleteDatabase_onblocked_duringVersionChange.js]
[test_event_source.js]
[test_getAll.js]
[test_globalObjects_other.js]