2014-10-25 20:46:27 -07:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id={1075716}
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Install web app from manifest with application/manifest+json MIME type</title>
|
|
|
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.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={1075716}">Mozilla Bug {1075716}</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="application/javascript;version=1.7">
|
|
|
|
|
2015-02-09 05:39:07 -08:00
|
|
|
var gIconData =
|
|
|
|
"\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52" +
|
|
|
|
"\x00\x00\x00\x0F\x00\x00\x00\x0F\x08\x03\x00\x00\x00\x0C\x08\x65" +
|
|
|
|
"\x78\x00\x00\x00\x04\x67\x41\x4D\x41\x00\x00\xD6\xD8\xD4\x4F\x58" +
|
|
|
|
"\x32\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6F\x66\x74\x77\x61\x72" +
|
|
|
|
"\x65\x00\x41\x64\x6F\x62\x65\x20\x49\x6D\x61\x67\x65\x52\x65\x61" +
|
|
|
|
"\x64\x79\x71\xC9\x65\x3C\x00\x00\x00\x39\x50\x4C\x54\x45\xB5\x42" +
|
|
|
|
"\x42\xCE\x94\x94\xCE\x84\x84\x9C\x21\x21\xAD\x21\x21\xCE\x73\x73" +
|
|
|
|
"\x9C\x10\x10\xBD\x52\x52\xEF\xD6\xD6\xB5\x63\x63\xA5\x10\x10\xB5" +
|
|
|
|
"\x00\x00\xE7\xC6\xC6\xE7\xB5\xB5\x9C\x00\x00\x8C\x00\x00\xFF\xFF" +
|
|
|
|
"\xFF\x7B\x00\x00\xAD\x00\x00\xEC\xAD\x83\x63\x00\x00\x00\x66\x49" +
|
|
|
|
"\x44\x41\x54\x78\xDA\x6C\x89\x0B\x12\xC2\x40\x08\x43\xB3\xDB\x8F" +
|
|
|
|
"\x5A\x21\x40\xEF\x7F\x58\xA1\x55\x67\xB6\xD3\xC0\x03\x42\xF0\xDE" +
|
|
|
|
"\x87\xC2\x3E\xEA\xCE\xF3\x4B\x0D\x30\x27\xAB\xCF\x03\x9C\xFB\xA3" +
|
|
|
|
"\xEB\xBC\x2D\xBA\xD4\x0F\x84\x97\x9E\x49\x67\xE5\x74\x87\x26\x70" +
|
|
|
|
"\x21\x0D\x66\xAE\xB6\x26\xB5\x8D\xE5\xE5\xCF\xB4\x9E\x79\x1C\xB9" +
|
|
|
|
"\x4C\x2E\xB0\x90\x16\x96\x84\xB6\x68\x2F\x84\x45\xF5\x0F\xC4\xA8" +
|
|
|
|
"\xAB\xFF\x08\x30\x00\x16\x91\x0C\xDD\xAB\xF1\x05\x11\x00\x00\x00" +
|
|
|
|
"\x00\x49\x45\x4E\x44\xAE\x42\x60\x82";
|
|
|
|
|
|
|
|
var gAlternateIconData =
|
|
|
|
"\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52" +
|
|
|
|
"\x00\x00\x00\x0F\x00\x00\x00\x0F\x08\x02\x00\x00\x00\xB4\xB4\x02" +
|
|
|
|
"\x1D\x00\x00\x00\xA7\x49\x44\x41\x54\x28\x15\x63\x64\x95\x9D\xC0" +
|
|
|
|
"\x40\x34\x60\x22\x5A\x25\x48\xE1\x50\x55\xCD\x02\xF1\xE5\xAF\x47" +
|
|
|
|
"\xF9\xC8\xDE\x7D\x79\xE3\x86\xB8\x86\x06\x44\x64\x6F\x67\x9B\xE7" +
|
|
|
|
"\x54\x6E\x08\x1B\xC5\x97\x0B\x7C\x5C\x6F\xEF\xDC\x06\x94\x00\x2A" +
|
|
|
|
"\x05\xB2\x81\x08\xC8\x56\x72\x70\x82\x28\x05\x92\x50\xB3\x81\x2C" +
|
|
|
|
"\xA0\xBA\x5B\xD7\x8F\x3C\xCF\xBF\x54\x79\xE3\x25\x84\x0D\x51\xF4" +
|
|
|
|
"\xE7\xC3\x3B\xB8\x6A\x84\xD9\x2C\x02\x42\x40\xD1\xCF\xBF\x3F\x01" +
|
|
|
|
"\x49\x08\x1B\xA2\x08\x85\x0D\xD7\x07\x31\xE3\xC3\xEF\xBF\x40\x11" +
|
|
|
|
"\x64\xF3\x20\x0A\x80\x1E\xBB\x7F\xF2\x04\xD4\x25\x40\xD6\xB3\xFB" +
|
|
|
|
"\x0F\x80\x4A\x05\x58\x99\xE1\x6C\xA0\x3A\xA0\x93\x80\xE2\x40\xC6" +
|
|
|
|
"\xC1\x19\xD3\x1E\x5F\x3C\xCF\x38\x68\xD2\x09\x00\x73\x68\x4B\x47" +
|
|
|
|
"\x39\xF8\xEA\x1A\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82";
|
|
|
|
|
|
|
|
|
2014-10-25 20:46:27 -07:00
|
|
|
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) {
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function finish() {
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
function cbError(aEvent) {
|
|
|
|
ok(false, "Error callback invoked " +
|
|
|
|
aEvent.target.error.name + " " + aEvent.target.error.message);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
|
2015-02-09 05:39:07 -08:00
|
|
|
function iconTest(app, iconSize, entryPoint, testFunction) {
|
|
|
|
navigator.mozApps.mgmt.getIcon(app, iconSize, entryPoint).then((blob) => {
|
|
|
|
var reader = new FileReader();
|
|
|
|
reader.onloadend = function() {
|
|
|
|
testFunction(reader.result);
|
|
|
|
continueTest();
|
|
|
|
}
|
|
|
|
reader.readAsBinaryString(blob);
|
|
|
|
}, (err) => {
|
|
|
|
ok(false, "Couldn't get icon.");
|
|
|
|
finish();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-10-25 20:46:27 -07:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Install a web app from a manifest with application/manifest+json MIME type.
|
|
|
|
*/
|
|
|
|
function runTest() {
|
|
|
|
SpecialPowers.setAllAppsLaunchable(true);
|
|
|
|
|
|
|
|
var manifestURL = "http://test/tests/dom/apps/tests/file_manifest.json";
|
|
|
|
|
|
|
|
SpecialPowers.autoConfirmAppInstall(continueTest);
|
|
|
|
yield undefined;
|
|
|
|
|
|
|
|
SpecialPowers.autoConfirmAppUninstall(continueTest);
|
|
|
|
yield undefined;
|
|
|
|
|
|
|
|
var request = navigator.mozApps.mgmt.getAll();
|
|
|
|
request.onerror = cbError;
|
|
|
|
request.onsuccess = continueTest;
|
|
|
|
yield undefined;
|
|
|
|
var initialAppsCount = request.result.length;
|
|
|
|
info("Starting with " + initialAppsCount + " apps installed.");
|
|
|
|
|
|
|
|
var request = navigator.mozApps.install(manifestURL, { });
|
|
|
|
request.onerror = cbError;
|
|
|
|
request.onsuccess = continueTest;
|
|
|
|
yield undefined;
|
|
|
|
|
|
|
|
var app = request.result;
|
|
|
|
ok(app, "App is non-null");
|
|
|
|
is(app.manifestURL, manifestURL, "App manifest url is correct.");
|
|
|
|
|
2015-02-09 05:39:07 -08:00
|
|
|
info("Fetching 15x15 icon");
|
|
|
|
iconTest(app, 15, undefined, (iconData) => {
|
|
|
|
is(iconData, gIconData, "Fetches 15x15 icon successfully.")
|
|
|
|
});
|
|
|
|
yield undefined;
|
|
|
|
|
|
|
|
info("Fetching 48x48 icon");
|
|
|
|
iconTest(app, 48, "ep1", (iconData) => {
|
|
|
|
ok(iconData.length == 4762, "Fetches 48x48 icon successfully.")
|
|
|
|
});
|
|
|
|
yield undefined;
|
|
|
|
|
|
|
|
info("Fetching 30x30 icon");
|
|
|
|
iconTest(app, 30, undefined, (iconData) => {
|
|
|
|
is(iconData, gIconData, "Fetches 15x15 icon as best fit for 30x30.")
|
|
|
|
});
|
|
|
|
yield undefined;
|
|
|
|
|
|
|
|
info("Fetching entry-point icon");
|
|
|
|
iconTest(app, 15, "ep1", (iconData) => {
|
|
|
|
is(iconData, gAlternateIconData, "Entry-point Icon fetched successfully.")
|
|
|
|
});
|
|
|
|
yield undefined;
|
|
|
|
|
2014-10-25 20:46:27 -07:00
|
|
|
request = navigator.mozApps.mgmt.uninstall(app);
|
|
|
|
request.onerror = cbError;
|
|
|
|
request.onsuccess = continueTest;
|
|
|
|
yield undefined;
|
|
|
|
is(request.result, manifestURL, "App uninstalled.");
|
|
|
|
|
|
|
|
request = navigator.mozApps.mgmt.getAll();
|
|
|
|
request.onerror = cbError;
|
|
|
|
request.onsuccess = continueTest;
|
|
|
|
yield undefined;
|
|
|
|
is(request.result.length, initialAppsCount, "Correct number of apps.");
|
|
|
|
}
|
|
|
|
|
|
|
|
addLoadEvent(go);
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|