michael@0: SimpleTest.waitForExplicitFinish(); michael@0: SpecialPowers.setAllAppsLaunchable(true); michael@0: michael@0: var fileTestOnCurrentOrigin = 'http://example.org/tests/dom/tests/mochitest/webapps/file_bug_779982.html'; michael@0: michael@0: var gData = [ michael@0: // APP 1 michael@0: { michael@0: app: 'http://example.org/manifest.webapp', michael@0: action: 'getSelf', michael@0: isnull: false, michael@0: src: fileTestOnCurrentOrigin, michael@0: message: 'getSelf() for app should return something' michael@0: }, michael@0: { michael@0: app: 'http://example.org/manifest.webapp', michael@0: action: 'checkInstalled', michael@0: isnull: false, michael@0: src: fileTestOnCurrentOrigin, michael@0: message: 'checkInstalled() for app should return true' michael@0: }, michael@0: { michael@0: app: 'http://example.org/manifest.webapp', michael@0: action: 'checkInstalledWrong', michael@0: isnull: true, michael@0: src: fileTestOnCurrentOrigin, michael@0: message: 'checkInstalled() for browser should return true' michael@0: }, michael@0: // Browser michael@0: { michael@0: browser: true, michael@0: action: 'getSelf', michael@0: isnull: true, michael@0: src: fileTestOnCurrentOrigin, michael@0: message: 'getSelf() for browser should return null' michael@0: }, michael@0: { michael@0: browser: true, michael@0: action: 'checkInstalled', michael@0: isnull: false, michael@0: src: fileTestOnCurrentOrigin, michael@0: message: 'checkInstalled() for browser should return true' michael@0: }, michael@0: { michael@0: browser: true, michael@0: action: 'checkInstalledWrong', michael@0: isnull: true, michael@0: src: fileTestOnCurrentOrigin, michael@0: message: 'checkInstalled() for browser should return true' michael@0: }, michael@0: ]; michael@0: michael@0: function runTest() { michael@0: for (var i in gData) { michael@0: var iframe = document.createElement('iframe'); michael@0: var data = gData[i]; michael@0: michael@0: if (data.app) { michael@0: iframe.setAttribute('mozbrowser', ''); michael@0: iframe.setAttribute('mozapp', data.app); michael@0: } else if (data.browser) { michael@0: iframe.setAttribute('mozbrowser', ''); michael@0: } michael@0: michael@0: if (data.app || data.browser) { michael@0: iframe.addEventListener('mozbrowsershowmodalprompt', function(e) { michael@0: is(e.detail.message, 'success', data.message); michael@0: michael@0: i++; michael@0: if (i >= gData.length) { michael@0: SimpleTest.finish(); michael@0: } else { michael@0: gTestRunner.next(); michael@0: } michael@0: }); michael@0: } michael@0: michael@0: iframe.src = data.src + '?' + data.action + '&' + data.isnull; michael@0: document.getElementById('content').appendChild(iframe); michael@0: michael@0: yield undefined; michael@0: } michael@0: } michael@0: michael@0: var gTestRunner = runTest(); michael@0: michael@0: SpecialPowers.pushPrefEnv({"set": [["dom.mozBrowserFramesEnabled", true]]}, function() { michael@0: SpecialPowers.pushPermissions([{'type': 'browser', 'allow': true, 'context': document}, {'type': 'embed-apps', 'allow': true, 'context': document}], function() {gTestRunner.next() }); michael@0: });