1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
function makeAllAppsLaunchable() {
var Webapps = {};
SpecialPowers.Cu.import("resource://gre/modules/Webapps.jsm", Webapps);
var appRegistry = SpecialPowers.wrap(Webapps.DOMApplicationRegistry);
var originalValue = appRegistry.allAppsLaunchable;
appRegistry.allAppsLaunchable = true;
// Clean up after ourselves once tests are done so the test page is unloaded.
window.addEventListener("unload", function restoreAllAppsLaunchable(event) {
if (event.target == window.document) {
window.removeEventListener("unload", restoreAllAppsLaunchable, false);
appRegistry.allAppsLaunchable = originalValue;
}
}, false);
}
SimpleTest.waitForExplicitFinish();
makeAllAppsLaunchable();
var fileTestOnCurrentOrigin = 'http://example.org/tests/dom/tests/mochitest/webapps/file_bug_779982.html';
var previousPrefs = {
mozBrowserFramesEnabled: undefined,
oop_by_default: undefined,
};
try {
previousPrefs.mozBrowserFramesEnabled = SpecialPowers.getBoolPref('dom.mozBrowserFramesEnabled');
} catch(e)
{
}
SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', true);
SpecialPowers.addPermission("browser", true, window.document);
SpecialPowers.addPermission("embed-apps", true, window.document);
var gData = [
// APP 1
{
app: 'http://example.org/manifest.webapp',
action: 'getSelf',
isnull: false,
src: fileTestOnCurrentOrigin,
message: 'getSelf() for app should return something'
},
{
app: 'http://example.org/manifest.webapp',
action: 'checkInstalled',
isnull: false,
src: fileTestOnCurrentOrigin,
message: 'checkInstalled() for app should return true'
},
{
app: 'http://example.org/manifest.webapp',
action: 'checkInstalledWrong',
isnull: true,
src: fileTestOnCurrentOrigin,
message: 'checkInstalled() for browser should return true'
},
// Browser
{
browser: true,
action: 'getSelf',
isnull: true,
src: fileTestOnCurrentOrigin,
message: 'getSelf() for browser should return null'
},
{
browser: true,
action: 'checkInstalled',
isnull: false,
src: fileTestOnCurrentOrigin,
message: 'checkInstalled() for browser should return true'
},
{
browser: true,
action: 'checkInstalledWrong',
isnull: true,
src: fileTestOnCurrentOrigin,
message: 'checkInstalled() for browser should return true'
},
];
function runTest() {
for (var i in gData) {
var iframe = document.createElement('iframe');
var data = gData[i];
if (data.app) {
iframe.setAttribute('mozbrowser', '');
iframe.setAttribute('mozapp', data.app);
} else if (data.browser) {
iframe.setAttribute('mozbrowser', '');
}
if (data.app || data.browser) {
iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
is(e.detail.message, 'success', data.message);
i++;
if (i >= gData.length) {
if (previousPrefs.mozBrowserFramesEnabled !== undefined) {
SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', previousPrefs.mozBrowserFramesEnabled);
}
SpecialPowers.removePermission("browser", window.document);
SpecialPowers.removePermission("embed-apps", window.document);
SimpleTest.finish();
} else {
gTestRunner.next();
}
});
}
iframe.src = data.src + '?' + data.action + '&' + data.isnull;
document.getElementById('content').appendChild(iframe);
yield;
}
}
var gTestRunner = runTest();
gTestRunner.next();
|