/* Any copyright is dedicated to the public domain. http://creativecommons.org/publicdomain/zero/1.0/ */ // Helpers for managing the browser frame preferences. "use strict"; function _getPath() { return window.location.pathname .substring(0, window.location.pathname.lastIndexOf('/')) .replace("/priority", ""); } const browserElementTestHelpers = { _getBoolPref: function(pref) { try { return SpecialPowers.getBoolPref(pref); } catch (e) { return undefined; } }, _setPref: function(pref, value) { this.lockTestReady(); if (value !== undefined && value !== null) { SpecialPowers.pushPrefEnv({'set': [[pref, value]]}, this.unlockTestReady.bind(this)); } else { SpecialPowers.pushPrefEnv({'clear': [[pref]]}, this.unlockTestReady.bind(this)); } }, _testReadyLockCount: 0, _firedTestReady: false, lockTestReady: function() { this._testReadyLockCount++; }, unlockTestReady: function() { this._testReadyLockCount--; if (this._testReadyLockCount == 0 && !this._firedTestReady) { this._firedTestReady = true; dispatchEvent(new Event("testready")); } }, enableProcessPriorityManager: function() { this._setPref('dom.ipc.processPriorityManager.testMode', true); this._setPref('dom.ipc.processPriorityManager.enabled', true); }, setEnabledPref: function(value) { this._setPref('dom.mozBrowserFramesEnabled', value); }, getOOPByDefaultPref: function() { return this._getBoolPref("dom.ipc.browser_frames.oop_by_default"); }, addPermission: function() { SpecialPowers.addPermission("browser", true, document); this.tempPermissions.push(location.href) }, removeAllTempPermissions: function() { for(var i = 0; i < this.tempPermissions.length; i++) { SpecialPowers.removePermission("browser", this.tempPermissions[i]); } }, addPermissionForUrl: function(url) { SpecialPowers.addPermission("browser", true, url); this.tempPermissions.push(url); }, 'tempPermissions': [], // Some basically-empty pages from different domains you can load. 'emptyPage1': 'http://example.com' + _getPath() + '/file_empty.html', 'emptyPage2': 'http://example.org' + _getPath() + '/file_empty.html', 'emptyPage3': 'http://test1.example.org' + _getPath() + '/file_empty.html', 'focusPage': 'http://example.org' + _getPath() + '/file_focus.html', }; // Set some prefs: // // * browser.pageThumbs.enabled: false // // Disable tab view; it seriously messes us up. // // * dom.ipc.browser_frames.oop_by_default // // Enable or disable OOP-by-default depending on the test's filename. You // can still force OOP on or off with