summaryrefslogtreecommitdiffstats
path: root/dom/indexedDB/test/test_filehandle_disabled_pref.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/indexedDB/test/test_filehandle_disabled_pref.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/indexedDB/test/test_filehandle_disabled_pref.html')
-rw-r--r--dom/indexedDB/test/test_filehandle_disabled_pref.html204
1 files changed, 204 insertions, 0 deletions
diff --git a/dom/indexedDB/test/test_filehandle_disabled_pref.html b/dom/indexedDB/test/test_filehandle_disabled_pref.html
new file mode 100644
index 000000000..d695e10ee
--- /dev/null
+++ b/dom/indexedDB/test/test_filehandle_disabled_pref.html
@@ -0,0 +1,204 @@
+<!--
+ Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html>
+ <head>
+ <title>Indexed Database Property Test</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">
+ function testSteps()
+ {
+ const databaseName = window.location.pathname;
+ const databaseVersion = 1;
+ const objectStoreName = "foo";
+ const mutableFileName = "bar";
+ const mutableFileKey = 42;
+
+ info("opening database");
+
+ let request = indexedDB.open(databaseName, databaseVersion);
+ request.onerror = errorHandler;
+ request.onupgradeneeded = grabEventAndContinueHandler;
+ request.onsuccess = unexpectedSuccessHandler;
+ let event = yield undefined;
+
+ info("creating object store");
+
+ let db = event.target.result;
+ db.onerror = errorHandler;
+ db.onversionchange = function(event) {
+ is(event.oldVersion, databaseVersion, "got correct oldVersion");
+ is(event.newVersion, null, "got correct newVersion");
+ db.close();
+ };
+
+ let objectStore = db.createObjectStore(objectStoreName,
+ { autoIncrement: true });
+
+ request.onupgradeneeded = unexpectedSuccessHandler;
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ info("creating mutable file");
+
+ request = db.createMutableFile(mutableFileName);
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ let mutableFile = event.target.result;
+
+ verifyMutableFile(mutableFile, getFile(mutableFileName, "", ""));
+ yield undefined;
+
+ objectStore = db.transaction([objectStoreName], "readwrite")
+ .objectStore(objectStoreName);
+
+ info("adding mutable file");
+
+ request = objectStore.add(mutableFile, mutableFileKey);
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ info("getting mutable file");
+
+ request = objectStore.get(mutableFileKey);
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ verifyMutableFile(event.target.result,
+ getFile(mutableFileName, "", ""));
+ yield undefined;
+
+ info("opening database");
+
+ request = indexedDB.open(databaseName, databaseVersion);
+ request.onerror = errorHandler;
+ request.onupgradeneeded = unexpectedSuccessHandler;
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ let db2 = event.target.result;
+ db2.onerror = errorHandler;
+ db2.onversionchange = function(event) {
+ is(event.oldVersion, databaseVersion, "got correct oldVersion");
+ is(event.newVersion, null, "got correct newVersion");
+ db2.close();
+ };
+
+ objectStore = db2.transaction([objectStoreName], "readwrite")
+ .objectStore(objectStoreName);
+
+ info("adding mutable file");
+
+ request = objectStore.add(mutableFile);
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ info("getting mutable file");
+
+ request = objectStore.get(event.target.result);
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ verifyMutableFile(event.target.result,
+ getFile(mutableFileName, "", ""));
+ yield undefined;
+
+ info("setting file handle pref");
+
+ SpecialPowers.pushPrefEnv({ set: [["dom.fileHandle.enabled", false]] },
+ continueToNextStep);
+ yield undefined;
+
+ info("opening database");
+
+ request = indexedDB.open(databaseName, databaseVersion);
+ request.onerror = errorHandler;
+ request.onupgradeneeded = unexpectedSuccessHandler;
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ let db3 = event.target.result;
+ db3.onerror = errorHandler;
+ db3.onversionchange = function(event) {
+ is(event.oldVersion, databaseVersion, "got correct oldVersion");
+ is(event.newVersion, null, "got correct newVersion");
+ db3.close();
+ };
+
+ info("creating mutable file");
+
+ try {
+ db3.createMutableFile(mutableFileName);
+ ok(false, "Should have thrown!");
+ }
+ catch (e) {
+ ok(e instanceof DOMException, "Got exception.");
+ is(e.name, "InvalidStateError", "Good error.");
+ is(e.code, DOMException.INVALID_STATE_ERR, "Good error code.");
+ }
+
+ objectStore = db3.transaction([objectStoreName], "readwrite")
+ .objectStore(objectStoreName);
+
+ info("adding mutable file");
+
+ try {
+ objectStore.add(mutableFile);
+ ok(false, "Should have thrown!");
+ }
+ catch (e) {
+ ok(e instanceof DOMException, "Got exception.");
+ is(e.name, "DataCloneError", "Good error.");
+ is(e.code, DOMException.DATA_CLONE_ERR, "Good error code.");
+ }
+
+ info("getting mutable file");
+
+ request = objectStore.get(mutableFileKey);
+ request.onsuccess = grabEventAndContinueHandler;
+ event = yield undefined;
+
+ try {
+ let result = request.result;
+ ok(false, "Should have thrown!");
+ }
+ catch (e) {
+ ok(e instanceof DOMException, "Got exception.");
+ is(e.name, "InvalidStateError", "Good error.");
+ is(e.code, DOMException.INVALID_STATE_ERR, "Good error code.");
+ }
+
+ info("deleting database");
+
+ request = indexedDB.deleteDatabase(databaseName);
+ request.onerror = errorHandler;
+ request.onsuccess = grabEventAndContinueHandler;
+
+ event = yield undefined;
+
+ info("resetting file handle pref");
+
+ SpecialPowers.popPrefEnv(continueToNextStep);
+ yield undefined;
+
+ finishTest();
+ yield undefined;
+ }
+ </script>
+
+ <script type="text/javascript;version=1.7" src="helpers.js"></script>
+ <script type="text/javascript;version=1.7" src="file.js"></script>
+
+ </head>
+
+ <body onload="runTest();"></body>
+
+</html>