mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
138 lines
4.3 KiB
HTML
138 lines
4.3 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" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
<script type="text/javascript;version=1.7">
|
|
"use strict";
|
|
|
|
const appDomain = "example.org";
|
|
const manifestURL =
|
|
location.protocol + "//" + appDomain + "/manifest.webapp";
|
|
|
|
function testSteps()
|
|
{
|
|
const objectStoreName = "foo";
|
|
const testKey = 1;
|
|
const testValue = objectStoreName;
|
|
|
|
let request = indexedDB.open(window.location.pathname, 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;
|
|
|
|
let srcURL =
|
|
location.protocol + "//" + appDomain +
|
|
location.pathname.replace("test_webapp_clearBrowserData.html",
|
|
"webapp_clearBrowserData_appFrame.html");
|
|
|
|
let iframe = document.createElement("iframe");
|
|
iframe.setAttribute("mozbrowser", "");
|
|
iframe.setAttribute("mozapp", manifestURL);
|
|
iframe.setAttribute("src", srcURL);
|
|
iframe.setAttribute("remote", "true");
|
|
iframe.addEventListener("mozbrowsershowmodalprompt", function(event) {
|
|
let message = JSON.parse(event.detail.message);
|
|
switch (message.type) {
|
|
case "info":
|
|
case "ok":
|
|
window[message.type].apply(window, message.args);
|
|
break;
|
|
case "done":
|
|
continueToNextStepSync();
|
|
break;
|
|
default:
|
|
throw "unknown message";
|
|
}
|
|
});
|
|
|
|
info("loading app frame");
|
|
|
|
document.body.appendChild(iframe);
|
|
yield;
|
|
|
|
request = indexedDB.open(window.location.pathname, 1);
|
|
request.onerror = errorHandler;
|
|
request.onupgradeneeded = unexpectedSuccessHandler;
|
|
request.onsuccess = grabEventAndContinueHandler;
|
|
event = yield;
|
|
|
|
db = event.target.result;
|
|
db.onerror = errorHandler;
|
|
|
|
objectStore =
|
|
db.transaction(objectStoreName).objectStore(objectStoreName);
|
|
objectStore.get(testKey).onsuccess = grabEventAndContinueHandler;
|
|
event = yield;
|
|
|
|
ok(testValue == event.target.result, "data still exists");
|
|
|
|
finishTest();
|
|
yield;
|
|
}
|
|
|
|
function start()
|
|
{
|
|
if (!SpecialPowers.isMainProcess()) {
|
|
todo(false, "Test disabled in child processes, for now");
|
|
SimpleTest.finish();
|
|
return;
|
|
}
|
|
|
|
SpecialPowers.addPermission("browser", true, document);
|
|
SpecialPowers.addPermission("browser", true, { manifestURL: manifestURL,
|
|
isInBrowserElement: false });
|
|
SpecialPowers.addPermission("embed-apps", true, document);
|
|
|
|
let Webapps = {};
|
|
SpecialPowers.wrap(Components)
|
|
.utils.import("resource://gre/modules/Webapps.jsm", Webapps);
|
|
let appRegistry = SpecialPowers.wrap(Webapps.DOMApplicationRegistry);
|
|
|
|
let originalAllAppsLaunchable = appRegistry.allAppsLaunchable;
|
|
appRegistry.allAppsLaunchable = true;
|
|
|
|
window.addEventListener("unload", function cleanup(event) {
|
|
if (event.target == document) {
|
|
window.removeEventListener("unload", cleanup, false);
|
|
|
|
SpecialPowers.removePermission("browser", location.href);
|
|
SpecialPowers.removePermission("browser",
|
|
location.protocol + "//" + appDomain);
|
|
SpecialPowers.removePermission("embed-apps", location.href);
|
|
appRegistry.allAppsLaunchable = originalAllAppsLaunchable;
|
|
}
|
|
}, false);
|
|
|
|
SpecialPowers.pushPrefEnv({
|
|
"set": [["dom.mozBrowserFramesEnabled", true]]
|
|
}, runTest);
|
|
}
|
|
</script>
|
|
|
|
<script type="text/javascript;version=1.7" src="helpers.js"></script>
|
|
</head>
|
|
|
|
<body onload="start();"></body>
|
|
|
|
</html>
|