mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
2fde96952c
From 7bb0fbba24f4f65d3fa83efe223b1431cd71fdb6 Mon Sep 17 00:00:00 2001 --- dom/apps/tests/test_third_party_homescreen.html | 8 +- .../test/test_messagemanager_assertpermission.html | 4 +- dom/base/test/test_messagemanager_targetchain.html | 16 +-- ...rowserElement_AllowEmbedAppsInNestedOOIframe.js | 11 +- .../mochitest/browserElement_CopyPaste.js | 9 +- .../browserElement_DisallowEmbedAppsInOOP.js | 9 +- .../mochitest/browserElement_Proxy.js | 10 +- .../browserElement_SetInputMethodActive.js | 3 +- .../mochitest/browserElement_SetVisibleFrames.js | 17 ++-- .../mochitest/browserElement_SetVisibleFrames2.js | 16 +-- .../priority/test_ExpectingSystemMessage2.html | 16 +-- .../mochitest/priority/test_NestedFrames.html | 16 +-- dom/cache/test/mochitest/driver.js | 11 +- .../test/mochitest/test_cache_orphaned_body.html | 33 +----- .../test/mochitest/test_cache_orphaned_cache.html | 33 +----- dom/cache/test/mochitest/test_cache_restart.html | 11 +- dom/cache/test/mochitest/test_cache_shrink.html | 33 +----- dom/indexedDB/test/file.js | 12 +-- dom/indexedDB/test/helpers.js | 9 +- dom/indexedDB/test/webapp_clearBrowserData.js | 6 +- dom/inputmethod/mochitest/test_bug1043828.html | 5 +- dom/inputmethod/mochitest/test_bug944397.html | 5 +- .../mochitest/test_focus_blur_manage_events.html | 5 +- .../mochitest/test_input_registry_events.html | 5 +- .../mochitest/test_simple_manage_events.html | 5 +- .../tests/test_permission_for_nested_oop_app.html | 3 +- .../tests/test_permission_for_two_oop_apps.html | 3 +- dom/ipc/tests/test_permission_helper.js | 21 ++-- .../test_permission_when_oop_app_crashes.html | 3 +- dom/tv/test/mochitest/head.js | 5 +- .../test_SpecialPowersPushAppPermissions.html | 14 ++- .../tests/Harness_sanity/test_bug816847.html | 6 +- .../components/SpecialPowersObserver.js | 4 +- .../content/SpecialPowersObserverAPI.js | 24 +---- testing/specialpowers/content/specialpowersAPI.js | 111 ++++++++------------- 35 files changed, 173 insertions(+), 329 deletions(-)
202 lines
5.9 KiB
HTML
202 lines
5.9 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id={1097468}
|
|
-->
|
|
<head>
|
|
<title>Test for Bug {1097468}</title>
|
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="text/javascript" src="common.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id={1097468}">Mozilla Bug {1097468}</a>
|
|
|
|
<script class="testbody" type="application/javascript;version=1.7">
|
|
|
|
var gManifestURL = "http://test/tests/dom/apps/tests/file_app.sjs?apptype=hosted&getmanifest=true";
|
|
var gGenerator = runTest();
|
|
|
|
const { Services } = SpecialPowers.Cu.import('resource://gre/modules/Services.jsm', {});
|
|
|
|
function runApp(aApp, aCallback) {
|
|
var ifr = document.createElement('iframe');
|
|
ifr.setAttribute('mozbrowser', 'true');
|
|
ifr.setAttribute('mozapp', aApp.manifestURL);
|
|
ifr.src = Services.io.newURI(aApp.manifestURL, null, null)
|
|
.resolve(aApp.manifest.launch_path);
|
|
|
|
ifr.addEventListener('mozbrowsershowmodalprompt', function onAlert(e) {
|
|
var message = e.detail.message;
|
|
info("Got message " + message);
|
|
|
|
if (message.startsWith("OK: ")) {
|
|
ok(true, message.substring(4, message.length));
|
|
} else if (message.startsWith("ERROR: ")) {
|
|
ok(false, message.substring(7, message.length));
|
|
} else if (message == "DONE") {
|
|
ifr.removeEventListener('mozbrowsershowmodalprompt', onAlert, false);
|
|
loadFrameScript(mm);
|
|
}
|
|
}, false);
|
|
|
|
document.body.appendChild(ifr);
|
|
|
|
var mm = SpecialPowers.getBrowserFrameMessageManager(ifr);
|
|
ok(mm, "mm is not null");
|
|
mm.addMessageListener('OK', function(msg) {
|
|
ok(true, "Message from app: " + SpecialPowers.wrap(msg).json);
|
|
});
|
|
mm.addMessageListener('KO', function(msg) {
|
|
ok(false, "Message from app: " + SpecialPowers.wrap(msg).json);
|
|
});
|
|
mm.addMessageListener('DONE', function() {
|
|
ok(true, "Message from app: complete");
|
|
document.body.removeChild(ifr);
|
|
aCallback();
|
|
});
|
|
|
|
// Test permission |homescreen-webapps-manage|
|
|
function frameScript()
|
|
{
|
|
function ok(p, msg) {
|
|
if (p) {
|
|
sendAsyncMessage("OK", msg);
|
|
} else {
|
|
sendAsyncMessage("KO", msg);
|
|
}
|
|
}
|
|
|
|
function is(a, b, msg) {
|
|
if (a == b) {
|
|
sendAsyncMessage("OK", a + " == " + b + " - " + msg);
|
|
} else {
|
|
sendAsyncMessage("KO", a + " != " + b + " - " + msg);
|
|
}
|
|
}
|
|
|
|
function finish() {
|
|
sendAsyncMessage("DONE", "");
|
|
}
|
|
|
|
if ('mgmt' in content.window.navigator.mozApps) {
|
|
ok(true, "get mgmt");
|
|
var mgmt = content.window.navigator.mozApps.mgmt;
|
|
is(typeof mgmt.getAll, "function", "get getAll");
|
|
is(typeof mgmt.uninstall, "function", "get uninstall");
|
|
is(typeof mgmt.oninstall, "object", "get oninstall");
|
|
is(typeof mgmt.onuninstall, "object", "get onuninstall");
|
|
is(typeof mgmt.onenabledstatechange, "object", "get onenabledstatechange");
|
|
|
|
[
|
|
"getNotInstalled",
|
|
"applyDownload",
|
|
"import",
|
|
"extractManifest",
|
|
"setEnabled"
|
|
].forEach(function(func) {
|
|
is(typeof mgmt[func], "undefined", "shouldn't get" + func);
|
|
});
|
|
} else {
|
|
ok(false, "can not get mgmt");
|
|
}
|
|
finish();
|
|
}
|
|
|
|
function loadFrameScript(mm) {
|
|
var script = "data:,(" + frameScript.toString() + ")();";
|
|
mm.loadFrameScript(script, /* allowDelayedLoad = */ false);
|
|
}
|
|
}
|
|
|
|
function go() {
|
|
SpecialPowers.pushPermissions(
|
|
[{ "type": "webapps-manage", "allow": 1, "context": document },
|
|
{ "type": "browser", "allow": 1, "context": document },
|
|
{ "type": "embed-apps", "allow": 1, "context": document }],
|
|
function() {
|
|
SpecialPowers.pushPrefEnv({'set': [["dom.mozBrowserFramesEnabled", true],
|
|
["dom.mozApps.homescreenURL",
|
|
gManifestURL]]}, continueTest)});
|
|
}
|
|
|
|
function continueTest() {
|
|
try {
|
|
gGenerator.next();
|
|
} catch (e if e instanceof StopIteration) {
|
|
finish();
|
|
}
|
|
}
|
|
|
|
function finish() {
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
function cbError(aEvent) {
|
|
ok(false, "Error callback invoked " +
|
|
aEvent.target.error.name + " " + aEvent.target.error.message);
|
|
finish();
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
/**
|
|
* Test third-party homescreen (permission |homescreen-webapps-manage|)
|
|
*/
|
|
function runTest() {
|
|
SpecialPowers.setAllAppsLaunchable(true);
|
|
|
|
SpecialPowers.autoConfirmAppInstall(continueTest);
|
|
yield undefined;
|
|
|
|
SpecialPowers.autoConfirmAppUninstall(continueTest);
|
|
yield undefined;
|
|
|
|
// Install a app.
|
|
var request = navigator.mozApps.install(gManifestURL, { });
|
|
request.onerror = cbError;
|
|
request.onsuccess = continueTest;
|
|
yield undefined;
|
|
|
|
var app = request.result;
|
|
ok(app, "App is non-null");
|
|
is(app.manifestURL, gManifestURL, "App manifest url is correct.");
|
|
|
|
var context = {manifestURL: app.manifestURL};
|
|
|
|
SpecialPowers.pushPermissions([{type: "homescreen-webapps-manage",
|
|
allow: 1,
|
|
context: context}], continueTest);
|
|
yield undefined;
|
|
|
|
// Launch the app.
|
|
info("Running " + app.manifestURL);
|
|
runApp(app, continueTest);
|
|
yield undefined;
|
|
|
|
// Uninstall the app to cleanup after ourself.
|
|
navigator.mozApps.mgmt.onuninstall = function(event) {
|
|
var app = event.application;
|
|
is(app.manifestURL, gManifestURL, "App uninstall event ok.");
|
|
is(app.manifest.name, "Really Rapid Release (hosted)",
|
|
"App uninstall manifest ok.");
|
|
continueTest();
|
|
}
|
|
request = navigator.mozApps.mgmt.uninstall(app);
|
|
request.onerror = cbError;
|
|
request.onsuccess = continueTest;
|
|
yield undefined;
|
|
yield undefined;
|
|
is(request.result, gManifestURL, "App uninstalled.");
|
|
navigator.mozApps.mgmt.onuninstall = null;
|
|
}
|
|
|
|
addLoadEvent(() => prepareEnv(go));
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|