michael@0: SimpleTest.waitForExplicitFinish(); michael@0: michael@0: var fileTestOnCurrentOrigin = (location.protocol + '//' + location.host + location.pathname) michael@0: .replace('test_', 'file_') michael@0: .replace('_inproc', '').replace('_oop', ''); michael@0: michael@0: var previousPrefs = { michael@0: mozBrowserFramesEnabled: undefined, michael@0: oop_by_default: undefined, michael@0: }; michael@0: michael@0: try { michael@0: previousPrefs.mozBrowserFramesEnabled = SpecialPowers.getBoolPref('dom.mozBrowserFramesEnabled'); michael@0: } catch(e) michael@0: { michael@0: } michael@0: michael@0: try { michael@0: previousPrefs.oop_by_default = SpecialPowers.getBoolPref('dom.ipc.browser_frames.oop_by_default'); michael@0: } catch(e) { michael@0: } michael@0: michael@0: SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', true); michael@0: SpecialPowers.setBoolPref("dom.ipc.browser_frames.oop_by_default", location.pathname.indexOf('_inproc') == -1); michael@0: michael@0: SpecialPowers.addPermission("browser", true, window.document); michael@0: michael@0: var gData = [ michael@0: // APP 1 michael@0: { michael@0: app: 'http://example.org/manifest.webapp', michael@0: action: 'read-no', michael@0: src: fileTestOnCurrentOrigin, michael@0: }, michael@0: { michael@0: app: 'http://example.org/manifest.webapp', michael@0: action: 'write', michael@0: src: fileTestOnCurrentOrigin, michael@0: }, michael@0: { michael@0: app: 'http://example.org/manifest.webapp', michael@0: action: 'read-yes', michael@0: src: fileTestOnCurrentOrigin, michael@0: }, michael@0: // APP 2 michael@0: { michael@0: app: 'https://example.com/manifest.webapp', michael@0: action: 'read-no', michael@0: src: fileTestOnCurrentOrigin, michael@0: }, michael@0: { michael@0: app: 'https://example.com/manifest.webapp', michael@0: action: 'write', michael@0: src: fileTestOnCurrentOrigin, michael@0: }, michael@0: { michael@0: app: 'https://example.com/manifest.webapp', michael@0: action: 'read-yes', michael@0: src: fileTestOnCurrentOrigin, michael@0: }, michael@0: // Browser michael@0: { michael@0: browser: true, michael@0: action: 'read-no', michael@0: src: fileTestOnCurrentOrigin, michael@0: }, michael@0: { michael@0: browser: true, michael@0: action: 'write', michael@0: src: fileTestOnCurrentOrigin, michael@0: }, michael@0: { michael@0: browser: true, michael@0: action: 'read-yes', michael@0: src: fileTestOnCurrentOrigin, 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', 'test number ' + i); michael@0: michael@0: // document.getElementById('content').removeChild(iframe); michael@0: michael@0: i++; michael@0: if (i >= gData.length) { michael@0: if (previousPrefs.mozBrowserFramesEnabled !== undefined) { michael@0: SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', previousPrefs.mozBrowserFramesEnabled); michael@0: } michael@0: if (previousPrefs.oop_by_default !== undefined) { michael@0: SpecialPowers.setBoolPref("dom.ipc.browser_frames.oop_by_default", previousPrefs.oop_by_default); michael@0: } michael@0: michael@0: SpecialPowers.removePermission("browser", window.document); michael@0: michael@0: indexedDB.deleteDatabase('AppIsolationTest').onsuccess = function() { michael@0: SimpleTest.finish(); michael@0: }; michael@0: } else { michael@0: gTestRunner.next(); michael@0: } michael@0: }); michael@0: } michael@0: michael@0: iframe.src = data.src + '?' + data.action; michael@0: 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: function startTest() { michael@0: var request = window.indexedDB.open('AppIsolationTest'); michael@0: var created = false; michael@0: michael@0: request.onupgradeneeded = function(event) { michael@0: created = true; michael@0: var db = event.target.result; michael@0: var data = [ michael@0: { id: "0", name: "foo" }, michael@0: ]; michael@0: var objectStore = db.createObjectStore("test", { keyPath: "id" }); michael@0: for (var i in data) { michael@0: objectStore.add(data[i]); michael@0: } michael@0: } michael@0: michael@0: request.onsuccess = function(event) { michael@0: var db = event.target.result; michael@0: is(created, true, "we should have created the db"); michael@0: michael@0: db.transaction("test").objectStore("test").get("0").onsuccess = function(event) { michael@0: is(event.target.result.name, 'foo', 'data have been written'); michael@0: db.close(); michael@0: michael@0: gTestRunner.next(); michael@0: }; michael@0: } michael@0: } michael@0: michael@0: // test_ipc.html executes all the tests in this directory in content process. michael@0: // It will fail on this one for the moment. michael@0: if (!SpecialPowers.isMainProcess()) { michael@0: todo(false, "We should make this work on content process"); michael@0: SimpleTest.finish(); michael@0: } else { michael@0: // TODO: remove unsetting network.disable.ipc.security as part of bug 820712 michael@0: SpecialPowers.pushPrefEnv({ michael@0: "set": [ michael@0: ["network.disable.ipc.security", true], michael@0: ] michael@0: }, startTest); michael@0: }