mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 4eba57a286d7 (bug 806168)
This commit is contained in:
parent
b20159c6c8
commit
cc82d0397b
@ -1,147 +1,151 @@
|
|||||||
/* Any copyright is dedicated to the Public Domain.
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
"use strict";
|
// This file has 4 leading spaces so that hg/git can tell that it's copied
|
||||||
|
// from test_webapp_clearBrowserData.html. We'll fix the indentation in
|
||||||
|
// the next commit.
|
||||||
|
|
||||||
const appDomain = "example.org";
|
"use strict";
|
||||||
const manifestURL =
|
|
||||||
location.protocol + "//" + appDomain + "/manifest.webapp";
|
|
||||||
|
|
||||||
function testSteps()
|
const appDomain = "example.org";
|
||||||
{
|
const manifestURL =
|
||||||
const objectStoreName = "foo";
|
location.protocol + "//" + appDomain + "/manifest.webapp";
|
||||||
const testKey = 1;
|
|
||||||
const testValue = objectStoreName;
|
|
||||||
|
|
||||||
// Determine whether the app and browser frames should be in or
|
function testSteps()
|
||||||
// out-of-process.
|
{
|
||||||
let remote_app, remote_browser;
|
const objectStoreName = "foo";
|
||||||
if (window.location.href.indexOf("inproc_oop") != -1) {
|
const testKey = 1;
|
||||||
remote_app = false;
|
const testValue = objectStoreName;
|
||||||
remote_browser = true;
|
|
||||||
}
|
|
||||||
else if (window.location.href.indexOf("oop_inproc") != -1) {
|
|
||||||
remote_app = true;
|
|
||||||
remote_browser = false;
|
|
||||||
}
|
|
||||||
else if (window.location.href.indexOf("inproc_inproc") != -1) {
|
|
||||||
remote_app = false;
|
|
||||||
remote_browser = false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ok(false, "Bad test filename!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let request = indexedDB.open(window.location.pathname, 1);
|
// Determine whether the app and browser frames should be in or
|
||||||
request.onerror = errorHandler;
|
// out-of-process.
|
||||||
request.onupgradeneeded = grabEventAndContinueHandler;
|
let remote_app, remote_browser;
|
||||||
request.onsuccess = unexpectedSuccessHandler;
|
if (window.location.href.indexOf("inproc_oop") != -1) {
|
||||||
let event = yield;
|
remote_app = false;
|
||||||
|
remote_browser = true;
|
||||||
|
}
|
||||||
|
else if (window.location.href.indexOf("oop_inproc") != -1) {
|
||||||
|
remote_app = true;
|
||||||
|
remote_browser = false;
|
||||||
|
}
|
||||||
|
else if (window.location.href.indexOf("inproc_inproc") != -1) {
|
||||||
|
remote_app = false;
|
||||||
|
remote_browser = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ok(false, "Bad test filename!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let db = event.target.result;
|
let request = indexedDB.open(window.location.pathname, 1);
|
||||||
db.onerror = errorHandler;
|
request.onerror = errorHandler;
|
||||||
db.onversionchange = function(event) {
|
request.onupgradeneeded = grabEventAndContinueHandler;
|
||||||
event.target.close();
|
request.onsuccess = unexpectedSuccessHandler;
|
||||||
}
|
let event = yield;
|
||||||
|
|
||||||
let objectStore = db.createObjectStore(objectStoreName);
|
let db = event.target.result;
|
||||||
objectStore.add(testValue, testKey);
|
db.onerror = errorHandler;
|
||||||
|
db.onversionchange = function(event) {
|
||||||
|
event.target.close();
|
||||||
|
}
|
||||||
|
|
||||||
request.onsuccess = grabEventAndContinueHandler;
|
let objectStore = db.createObjectStore(objectStoreName);
|
||||||
event = yield;
|
objectStore.add(testValue, testKey);
|
||||||
|
|
||||||
// We need to send both remote_browser and remote_app in the querystring
|
request.onsuccess = grabEventAndContinueHandler;
|
||||||
// because webapp_clearBrowserData_appFrame uses the path + querystring to
|
event = yield;
|
||||||
// create and open a database which it checks no other test has touched. If
|
|
||||||
// we sent only remote_browser, then we wouldn't be able to test both
|
|
||||||
// (remote_app==false, remote_browser==false) and (remote_app==true,
|
|
||||||
// remote_browser==false).
|
|
||||||
let srcURL = location.protocol + "//" + appDomain +
|
|
||||||
location.pathname.substring(0, location.pathname.lastIndexOf('/')) +
|
|
||||||
"/webapp_clearBrowserData_appFrame.html?" +
|
|
||||||
"remote_browser=" + remote_browser + "&" +
|
|
||||||
"remote_app=" + remote_app;
|
|
||||||
|
|
||||||
let iframe = document.createElement("iframe");
|
// We need to send both remote_browser and remote_app in the querystring
|
||||||
iframe.setAttribute("mozbrowser", "");
|
// because webapp_clearBrowserData_appFrame uses the path + querystring to
|
||||||
iframe.setAttribute("mozapp", manifestURL);
|
// create and open a database which it checks no other test has touched. If
|
||||||
iframe.setAttribute("src", srcURL);
|
// we sent only remote_browser, then we wouldn't be able to test both
|
||||||
iframe.setAttribute("remote", remote_app);
|
// (remote_app==false, remote_browser==false) and (remote_app==true,
|
||||||
iframe.addEventListener("mozbrowsershowmodalprompt", function(event) {
|
// remote_browser==false).
|
||||||
let message = JSON.parse(event.detail.message);
|
let srcURL = location.protocol + "//" + appDomain +
|
||||||
switch (message.type) {
|
location.pathname.substring(0, location.pathname.lastIndexOf('/')) +
|
||||||
case "info":
|
"/webapp_clearBrowserData_appFrame.html?" +
|
||||||
case "ok":
|
"remote_browser=" + remote_browser + "&" +
|
||||||
window[message.type].apply(window, message.args);
|
"remote_app=" + remote_app;
|
||||||
break;
|
|
||||||
case "done":
|
let iframe = document.createElement("iframe");
|
||||||
continueToNextStepSync();
|
iframe.setAttribute("mozbrowser", "");
|
||||||
break;
|
iframe.setAttribute("mozapp", manifestURL);
|
||||||
default:
|
iframe.setAttribute("src", srcURL);
|
||||||
throw "unknown message";
|
iframe.setAttribute("remote", remote_app);
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
info("loading app frame");
|
function start()
|
||||||
|
{
|
||||||
|
if (!SpecialPowers.isMainProcess()) {
|
||||||
|
todo(false, "Test disabled in child processes, for now");
|
||||||
|
SimpleTest.finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
document.body.appendChild(iframe);
|
SpecialPowers.addPermission("browser", true, document);
|
||||||
yield;
|
SpecialPowers.addPermission("browser", true, { manifestURL: manifestURL,
|
||||||
|
isInBrowserElement: false });
|
||||||
|
SpecialPowers.addPermission("embed-apps", true, document);
|
||||||
|
|
||||||
request = indexedDB.open(window.location.pathname, 1);
|
let Webapps = {};
|
||||||
request.onerror = errorHandler;
|
SpecialPowers.wrap(Components)
|
||||||
request.onupgradeneeded = unexpectedSuccessHandler;
|
.utils.import("resource://gre/modules/Webapps.jsm", Webapps);
|
||||||
request.onsuccess = grabEventAndContinueHandler;
|
let appRegistry = SpecialPowers.wrap(Webapps.DOMApplicationRegistry);
|
||||||
event = yield;
|
|
||||||
|
|
||||||
db = event.target.result;
|
let originalAllAppsLaunchable = appRegistry.allAppsLaunchable;
|
||||||
db.onerror = errorHandler;
|
appRegistry.allAppsLaunchable = true;
|
||||||
|
|
||||||
objectStore =
|
window.addEventListener("unload", function cleanup(event) {
|
||||||
db.transaction(objectStoreName).objectStore(objectStoreName);
|
if (event.target == document) {
|
||||||
objectStore.get(testKey).onsuccess = grabEventAndContinueHandler;
|
window.removeEventListener("unload", cleanup, false);
|
||||||
event = yield;
|
|
||||||
|
|
||||||
ok(testValue == event.target.result, "data still exists");
|
SpecialPowers.removePermission("browser", location.href);
|
||||||
|
SpecialPowers.removePermission("browser",
|
||||||
|
location.protocol + "//" + appDomain);
|
||||||
|
SpecialPowers.removePermission("embed-apps", location.href);
|
||||||
|
appRegistry.allAppsLaunchable = originalAllAppsLaunchable;
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
|
||||||
finishTest();
|
SpecialPowers.pushPrefEnv({
|
||||||
yield;
|
"set": [["dom.mozBrowserFramesEnabled", true]]
|
||||||
}
|
}, runTest);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user