mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-09-11 02:56:06 +00:00
125 lines
3.1 KiB
HTML
125 lines
3.1 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1168300
|
|
-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Test for Bug 1168300</title>
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="application/javascript" src="common.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
<script type="application/javascript;version=1.7">
|
|
|
|
/** Test for Bug 1168300 **/
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
var url = "http://test/tests/dom/apps/tests/file_manifest.json";
|
|
|
|
var gGenerator = runTest();
|
|
|
|
function go() {
|
|
SpecialPowers.pushPermissions(
|
|
[{ "type": "webapps-manage", "allow": 1, "context": document }],
|
|
function() { gGenerator.next() });
|
|
}
|
|
|
|
function continueTest() {
|
|
try {
|
|
gGenerator.next();
|
|
} catch (e if e instanceof StopIteration) {
|
|
SimpleTest.finish();
|
|
}
|
|
}
|
|
|
|
function mozAppsError() {
|
|
ok(false, "mozApps error: " + this.error.name);
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
function runTest() {
|
|
// Set up.
|
|
SpecialPowers.setAllAppsLaunchable(true);
|
|
SpecialPowers.autoConfirmAppInstall(continueTest);
|
|
yield undefined;
|
|
|
|
SpecialPowers.autoConfirmAppUninstall(continueTest);
|
|
yield undefined;
|
|
|
|
let request = navigator.mozApps.install(url);
|
|
request.onerror = mozAppsError;
|
|
request.onsuccess = continueTest;
|
|
yield undefined;
|
|
let app = request.result;
|
|
|
|
let _topic = "clear-origin-data";
|
|
let observer = new Observer(_topic);
|
|
observer.onobserve = function(subject, topic, data, count) {
|
|
ok(topic == _topic, "unknown topic " + topic);
|
|
|
|
let props = Object.getOwnPropertyNames(JSON.parse(data));
|
|
is(props.length, 1, "pattern should have one property");
|
|
is(props[0], 'appId', "pattern property should be appId");
|
|
|
|
observer.shutdown();
|
|
continueTest();
|
|
};
|
|
|
|
request = navigator.mozApps.mgmt.uninstall(app);
|
|
request.onerror = mozAppsError;
|
|
navigator.mozApps.mgmt.onuninstall = function(evt) {
|
|
if (evt.application.manifestURL != url) {
|
|
return;
|
|
}
|
|
|
|
ok(true, "got onuninstall event");
|
|
continueTest();
|
|
};
|
|
|
|
// we now wait for "clear-origin-data" notifications and onuninstall
|
|
// callback.
|
|
yield undefined;
|
|
yield undefined;
|
|
|
|
navigator.mozApps.mgmt.onuninstall = null;
|
|
}
|
|
|
|
function Observer(topic) {
|
|
this.topic = topic;
|
|
SpecialPowers.addObserver(this, topic, false);
|
|
}
|
|
Observer.prototype = {
|
|
topic: null,
|
|
|
|
count: 1,
|
|
|
|
callback: null,
|
|
|
|
observe: function(subject, topic, data) {
|
|
if (this.callback) this.callback(subject, topic, data, this.count++);
|
|
},
|
|
|
|
shutdown: function() {
|
|
SpecialPowers.removeObserver(this, this.topic);
|
|
},
|
|
|
|
set onobserve (callback) {
|
|
this.callback = callback;
|
|
}
|
|
};
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
</script>
|
|
</head>
|
|
<body onload="prepareEnv(go)">
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1168300">Mozilla Bug 1168300</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
<pre id="test">
|
|
</pre>
|
|
</body>
|
|
</html>
|