2012-09-26 17:47:57 +00:00
|
|
|
/* Any copyright is dedicated to the public domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
// Bug 777384 - Test mozapp permission.
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
2013-03-28 19:51:10 +00:00
|
|
|
browserElementTestHelpers.setEnabledPref(true);
|
|
|
|
browserElementTestHelpers.addPermission();
|
2012-09-26 17:47:57 +00:00
|
|
|
|
2014-04-17 20:43:04 +00:00
|
|
|
SpecialPowers.setAllAppsLaunchable(true);
|
2012-09-26 17:47:57 +00:00
|
|
|
|
|
|
|
function testAppElement(expectAnApp, callback) {
|
|
|
|
var iframe = document.createElement('iframe');
|
2014-10-31 02:39:15 +00:00
|
|
|
iframe.setAttribute('mozbrowser', 'true');
|
2012-09-26 17:47:57 +00:00
|
|
|
iframe.setAttribute('mozapp', 'http://example.org/manifest.webapp');
|
|
|
|
iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
|
|
|
|
is(e.detail.message == 'app', expectAnApp, e.detail.message);
|
|
|
|
SimpleTest.executeSoon(callback);
|
|
|
|
});
|
|
|
|
document.body.appendChild(iframe);
|
|
|
|
iframe.src = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_AppFramePermission.html';
|
|
|
|
}
|
|
|
|
|
|
|
|
function runTest() {
|
|
|
|
SpecialPowers.addPermission("embed-apps", true, document);
|
|
|
|
testAppElement(true, function() {
|
|
|
|
SpecialPowers.removePermission("embed-apps", document);
|
|
|
|
testAppElement(false, function() {
|
|
|
|
SimpleTest.finish();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-03-28 19:51:10 +00:00
|
|
|
addEventListener('testready', runTest);
|