Bug 663778 - Use flag instead of pref for mozafterpaint switch and highlighter noautohide r=jwalker

This commit is contained in:
Michael Ratcliffe 2014-03-13 15:38:37 +00:00
parent eb6c7c9e1d
commit 39a70a90a5
20 changed files with 127 additions and 7 deletions

View File

@ -19,6 +19,11 @@ const HOSTED_APP_MANIFEST = TEST_BASE + "hosted_app.manifest";
const PACKAGED_APP_DIR_PATH = getTestFilePath(".");
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
function addTab(url, targetWindow = window) {
info("Adding tab: " + url);

View File

@ -10,6 +10,11 @@ let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
Services.scriptloader.loadSubScript(testDir + "/helpers.js", this);
Services.scriptloader.loadSubScript(testDir + "/mockCommands.js", this);
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
function whenDelayedStartupFinished(aWindow, aCallback) {
Services.obs.addObserver(function observer(aSubject, aTopic) {
if (aWindow == aSubject) {

View File

@ -27,6 +27,11 @@ let Toolbox = devtools.Toolbox;
const EXAMPLE_URL = "http://example.com/browser/browser/devtools/debugger/test/";
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
// All tests are asynchronous.
waitForExplicitFinish();

View File

@ -16,6 +16,11 @@ function test() {
let viewDoc;
let inspector;
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function onload() {
gBrowser.selectedBrowser.removeEventListener("load", onload, true);

View File

@ -32,6 +32,8 @@ this.DevTools = function DevTools() {
this.destroy = this.destroy.bind(this);
this._teardown = this._teardown.bind(this);
this._testing = false;
EventEmitter.decorate(this);
Services.obs.addObserver(this._teardown, "devtools-unloaded", false);
@ -39,6 +41,29 @@ this.DevTools = function DevTools() {
}
DevTools.prototype = {
/**
* When the testing flag is set we take appropriate action to prevent race
* conditions in our testing environment. This means setting
* dom.send_after_paint_to_content to false to prevent infinite MozAfterPaint
* loops and not autohiding the highlighter.
*/
get testing() {
return this._testing;
},
set testing(state) {
this._testing = state;
if (state) {
// dom.send_after_paint_to_content is set to true (non-default) in
// testing/profiles/prefs_general.js so lets set it to the same as it is
// in a default browser profile for the duration of the test.
Services.prefs.setBoolPref("dom.send_after_paint_to_content", false);
} else {
Services.prefs.setBoolPref("dom.send_after_paint_to_content", true);
}
},
/**
* Register a new developer tool.
*

View File

@ -13,6 +13,11 @@ let promise = tempScope.Promise;
let {devtools} = Components.utils.import("resource://gre/modules/devtools/Loader.jsm", {});
let TargetFactory = devtools.TargetFactory;
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
/**
* Open a new tab at a URL and call a callback on load
*/

View File

@ -1432,11 +1432,16 @@ ToolboxHighlighterUtils.prototype = {
* Hide the highlighter.
* @return a promise that resolves when the highlighter is hidden
*/
unhighlight: function() {
unhighlight: function(forceHide=false) {
if (this.isRemoteHighlightable) {
// If the remote highlighter exists on the target, use it
return this.toolbox.initInspector().then(() => {
return this.toolbox.highlighter.hideBoxModel();
let autohide = forceHide || !gDevTools.testing;
if (autohide) {
return this.toolbox.highlighter.hideBoxModel();
}
return promise.resolve();
});
} else {
// If not, no need to unhighlight as the older highlight method uses a

View File

@ -27,6 +27,11 @@ let console = tempScope.console;
let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
Services.scriptloader.loadSubScript(testDir + "../../../commandline/test/helpers.js", this);
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
SimpleTest.registerCleanupFunction(() => {
console.error("Here we are\n");
let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});

View File

@ -7,6 +7,11 @@ let TargetFactory = devtools.TargetFactory;
function test() {
waitForExplicitFinish();
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
Services.prefs.setBoolPref("devtools.inspector.sidebarOpen", true);
let doc;

View File

@ -12,6 +12,11 @@ let {getInplaceEditorForSpan: inplaceEditor} = devtools.require("devtools/shared
//Services.prefs.setBoolPref("devtools.dump.emit", true);
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
// Clear preferences that may be set during the course of tests.
function clearUserPrefs() {
Services.prefs.clearUserPref("devtools.inspector.htmlPanelOpen");

View File

@ -43,6 +43,11 @@ const SORTING_SJS = EXAMPLE_URL + "sjs_sorting-test-server.sjs";
const TEST_IMAGE = EXAMPLE_URL + "test-image.png";
const TEST_IMAGE_DATA_URI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==";
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
// All tests are asynchronous.
waitForExplicitFinish();
@ -55,6 +60,7 @@ const gDefaultFilters = Services.prefs.getCharPref("devtools.netmonitor.filters"
registerCleanupFunction(() => {
info("finish() was called, cleaning up...");
Services.prefs.setBoolPref("devtools.debugger.log", gEnableLogging);
Services.prefs.setCharPref("devtools.netmonitor.filters", gDefaultFilters);
});

View File

@ -23,6 +23,11 @@ let DebuggerServer = temp.DebuggerServer;
let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
Services.scriptloader.loadSubScript(testDir + "../../../commandline/test/helpers.js", this);
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
registerCleanupFunction(function () {
helpers = null;
Services.prefs.clearUserPref(PROFILER_ENABLED);

View File

@ -10,6 +10,11 @@ let TargetFactory = devtools.TargetFactory;
let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
Services.scriptloader.loadSubScript(testDir + "../../../commandline/test/helpers.js", this);
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
function openInspector(callback)
{
let target = TargetFactory.forTab(gBrowser.selectedTab);

View File

@ -10,6 +10,11 @@ const {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm", {});
let gScratchpadWindow; // Reference to the Scratchpad chrome window object
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
/**
* Open a Scratchpad window.
*

View File

@ -6,6 +6,11 @@ let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
let TargetFactory = devtools.TargetFactory;
let {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
/**
* Open a new tab at a URL and call a callback on load
*/

View File

@ -8,6 +8,11 @@ const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {})
const { require } = devtools;
const Editor = require("devtools/sourceeditor/editor");
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
function setup(cb) {
const opt = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
const url = "data:text/xml;charset=UTF-8,<?xml version='1.0'?>" +

View File

@ -23,6 +23,11 @@ let cache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
Services.scriptloader.loadSubScript(testDir + "../../../commandline/test/helpers.js", this);
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
function cleanup()
{
gPanelWindow = null;

View File

@ -9,11 +9,6 @@ const TEST_BASE_HTTPS = "https://example.com/browser/browser/devtools/styleinspe
//Services.prefs.setBoolPref("devtools.dump.emit", true);
Services.prefs.setBoolPref("devtools.debugger.log", true);
SimpleTest.registerCleanupFunction(() => {
Services.prefs.clearUserPref("devtools.debugger.log");
Services.prefs.clearUserPref("devtools.dump.emit");
});
let tempScope = {};
Cu.import("resource:///modules/devtools/gDevTools.jsm", tempScope);
@ -30,6 +25,16 @@ let {CssLogic, CssSelector} = devtools.require("devtools/styleinspector/css-logi
let promise = devtools.require("sdk/core/promise");
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
SimpleTest.registerCleanupFunction(() => {
Services.prefs.clearUserPref("devtools.debugger.log");
Services.prefs.clearUserPref("devtools.dump.emit");
});
let {
editableField,
getInplaceEditorForSpan: inplaceEditor

View File

@ -56,6 +56,10 @@ const NODE_REMOVED = Tilt.NOTIFICATIONS.NODE_REMOVED;
const TILT_ENABLED = Services.prefs.getBoolPref("devtools.tilt.enabled");
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
function isTiltEnabled() {
info("Apparently, Tilt is" + (TILT_ENABLED ? "" : " not") + " enabled.");

View File

@ -40,6 +40,11 @@ const GROUP_INDENT_DEFAULT = 6;
const WEBCONSOLE_STRINGS_URI = "chrome://browser/locale/devtools/webconsole.properties";
let WCU_l10n = new WebConsoleUtils.l10n(WEBCONSOLE_STRINGS_URI);
gDevTools.testing = true;
SimpleTest.registerCleanupFunction(() => {
gDevTools.testing = false;
});
function log(aMsg)
{
dump("*** WebConsoleTest: " + aMsg + "\n");