mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
caca0b9c6a
These new tests are disabled on Android because the test they're replacing, test_webapp_clearBrowserData.html, was also disabled on Android, and the new tests fail in the same way as the original test. --HG-- rename : dom/indexedDB/test/test_webapp_clearBrowserData.html => dom/indexedDB/test/webapp_clearBrowserData.js
105 lines
2.6 KiB
HTML
105 lines
2.6 KiB
HTML
<!--
|
|
Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/
|
|
-->
|
|
<html>
|
|
<head>
|
|
<title>Indexed Database Clear Browser Data Test</title>
|
|
|
|
<script type="text/javascript;version=1.7">
|
|
"use strict";
|
|
|
|
function ok(cond, message)
|
|
{
|
|
alert(JSON.stringify({ type: "ok",
|
|
args: [!!cond, "browserFrame: " + message] }));
|
|
}
|
|
|
|
function info(message)
|
|
{
|
|
alert(JSON.stringify({ type: "info",
|
|
args: ["browserFrame: " + message] }));
|
|
}
|
|
|
|
function block()
|
|
{
|
|
info("about to block");
|
|
|
|
// This will block until the parent has cleared our database.
|
|
alert(JSON.stringify({ type: "block" }));
|
|
|
|
info("unblocked");
|
|
}
|
|
|
|
function finish()
|
|
{
|
|
alert(JSON.stringify({ type: "done" }));
|
|
}
|
|
|
|
window.onerror = ok.bind(window, false);
|
|
|
|
function testSteps()
|
|
{
|
|
const objectStoreName = "foo";
|
|
const testKey = 1;
|
|
const testValue = objectStoreName;
|
|
const dbName = window.location.pathname + window.location.search;
|
|
|
|
let request = indexedDB.open(dbName, 1);
|
|
request.onerror = errorHandler;
|
|
request.onupgradeneeded = grabEventAndContinueHandler;
|
|
request.onsuccess = unexpectedSuccessHandler;
|
|
let event = yield;
|
|
|
|
let db = event.target.result;
|
|
db.onerror = errorHandler;
|
|
db.onversionchange = function(event) {
|
|
event.target.close();
|
|
}
|
|
|
|
let objectStore = db.createObjectStore(objectStoreName);
|
|
objectStore.add(testValue, testKey);
|
|
|
|
request.onsuccess = grabEventAndContinueHandler;
|
|
event = yield;
|
|
|
|
ok(db === event.target.result, "created database");
|
|
|
|
objectStore =
|
|
db.transaction(objectStoreName).objectStore(objectStoreName);
|
|
objectStore.get(testKey).onsuccess = grabEventAndContinueHandler;
|
|
event = yield;
|
|
|
|
ok(testValue == event.target.result, "data exists");
|
|
|
|
block();
|
|
|
|
request = indexedDB.open(dbName, 1);
|
|
request.onerror = errorHandler;
|
|
request.onupgradeneeded = grabEventAndContinueHandler;
|
|
request.onsuccess = unexpectedSuccessHandler;
|
|
event = yield;
|
|
|
|
ok(event.type == "upgradeneeded", "db doesn't exist");
|
|
|
|
request.onsuccess = grabEventAndContinueHandler;
|
|
event = yield;
|
|
|
|
db = event.target.result;
|
|
info(db.objectStoreNames.length);
|
|
ok(!db.objectStoreNames.length, "no object stores");
|
|
|
|
finish();
|
|
|
|
yield;
|
|
}
|
|
|
|
</script>
|
|
|
|
<script type="text/javascript;version=1.7" src="helpers.js"></script>
|
|
</head>
|
|
|
|
<body onload="testGenerator.next();"></body>
|
|
|
|
</html>
|