2015-05-27 08:10:42 +00:00
|
|
|
<!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>
|
2015-08-30 20:30:21 +00:00
|
|
|
<script type="application/javascript" src="common.js"></script>
|
2015-05-27 08:10:42 +00:00
|
|
|
<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;
|
|
|
|
|
2015-07-09 19:14:26 +00:00
|
|
|
let _topic = "clear-origin-data";
|
2015-05-27 08:10:42 +00:00
|
|
|
let observer = new Observer(_topic);
|
|
|
|
observer.onobserve = function(subject, topic, data, count) {
|
|
|
|
ok(topic == _topic, "unknown topic " + topic);
|
|
|
|
|
2015-07-09 19:14:26 +00:00
|
|
|
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");
|
2015-05-27 08:10:42 +00:00
|
|
|
|
2015-07-09 19:14:26 +00:00
|
|
|
observer.shutdown();
|
|
|
|
continueTest();
|
2015-05-27 08:10:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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();
|
|
|
|
};
|
|
|
|
|
2015-07-09 19:14:26 +00:00
|
|
|
// we now wait for "clear-origin-data" notifications and onuninstall
|
2015-05-27 08:10:42 +00:00
|
|
|
// 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>
|
2015-08-30 20:30:21 +00:00
|
|
|
<body onload="prepareEnv(go)">
|
2015-05-27 08:10:42 +00:00
|
|
|
<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>
|