Bug 719849 - global variables pollute the browser window during devtools tests; r=rcampbell

This commit is contained in:
Dao Gottwald 2012-01-23 11:50:11 -04:00
parent a860fa4f59
commit 706992fd3b
47 changed files with 144 additions and 61 deletions

View File

@ -8918,9 +8918,10 @@ var TabContextMenu = {
};
XPCOMUtils.defineLazyGetter(this, "HUDConsoleUI", function () {
Cu.import("resource:///modules/HUDService.jsm");
let tempScope = {};
Cu.import("resource:///modules/HUDService.jsm", tempScope);
try {
return HUDService.consoleUI;
return tempScope.HUDService.consoleUI;
}
catch (ex) {
Components.utils.reportError(ex);

View File

@ -92,8 +92,7 @@ function ruleViewOpened1()
prop.setEnabled(false);
// Open second tab and switch to it
tab2 = gBrowser.addTab();
gBrowser.selectedTab = tab2;
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function(evt) {
gBrowser.selectedBrowser.removeEventListener(evt.type, arguments.callee,

View File

@ -37,7 +37,9 @@
* ***** END LICENSE BLOCK ***** */
const Cu = Components.utils;
Cu.import("resource:///modules/devtools/LayoutHelpers.jsm");
let tempScope = {};
Cu.import("resource:///modules/devtools/LayoutHelpers.jsm", tempScope);
let LayoutHelpers = tempScope.LayoutHelpers;
function isHighlighting()
{

View File

@ -2,8 +2,11 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
let tempScope = {};
Cu.import("resource://gre/modules/NetUtil.jsm", tempScope);
Cu.import("resource://gre/modules/FileUtils.jsm", tempScope);
let NetUtil = tempScope.NetUtil;
let FileUtils = tempScope.FileUtils;
// Reference to the Scratchpad chrome window object.
let gScratchpadWindow;

View File

@ -2,9 +2,11 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
let tempScope = {};
Cu.import("resource://gre/modules/NetUtil.jsm", tempScope);
Cu.import("resource://gre/modules/FileUtils.jsm", tempScope);
let NetUtil = tempScope.NetUtil;
let FileUtils = tempScope.FileUtils;
// only finish() when correct number of tests are done
const expected = 5;

View File

@ -4,7 +4,9 @@
"use strict";
Cu.import("resource:///modules/source-editor.jsm");
let tempScope = {};
Cu.import("resource:///modules/source-editor.jsm", tempScope);
let SourceEditor = tempScope.SourceEditor;
function test()
{

View File

@ -75,6 +75,7 @@ function runTests()
sp.run();
is(window.foobarBug636725, "aloha2", "window.foobarBug636725 has been set");
delete window.foobarBug636725;
sp.setText("gBrowser", 7);

View File

@ -2,8 +2,11 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
let tempScope = {};
Cu.import("resource://gre/modules/NetUtil.jsm", tempScope);
Cu.import("resource://gre/modules/FileUtils.jsm", tempScope);
let NetUtil = tempScope.NetUtil;
let FileUtils = tempScope.FileUtils;
// Reference to the Scratchpad object.
let gScratchpad;

View File

@ -3,7 +3,9 @@
// Tests that our Promise implementation works properly
Cu.import("resource:///modules/devtools/Promise.jsm");
let tempScope = {};
Cu.import("resource:///modules/devtools/Promise.jsm", tempScope);
let Promise = tempScope.Promise;
function test() {
addTab("about:blank", function() {

View File

@ -3,8 +3,11 @@
// Tests that the DOM Template engine works properly
Cu.import("resource:///modules/devtools/Templater.jsm");
Cu.import("resource:///modules/devtools/Promise.jsm");
let tempScope = {};
Cu.import("resource:///modules/devtools/Templater.jsm", tempScope);
Cu.import("resource:///modules/devtools/Promise.jsm", tempScope);
let template = tempScope.template;
let Promise = tempScope.Promise;
function test() {
addTab("http://example.com/browser/browser/devtools/shared/test/browser_templater_basic.html", function() {

View File

@ -4,7 +4,9 @@
"use strict";
Cu.import("resource:///modules/source-editor.jsm");
let tempScope = {};
Cu.import("resource:///modules/source-editor.jsm", tempScope);
let SourceEditor = tempScope.SourceEditor;
let testWin;
let editor;

View File

@ -4,7 +4,9 @@
"use strict";
Cu.import("resource:///modules/source-editor.jsm");
let tempScope = {};
Cu.import("resource:///modules/source-editor.jsm", tempScope);
let SourceEditor = tempScope.SourceEditor;
let testWin;
let editor;

View File

@ -4,7 +4,9 @@
"use strict";
Cu.import("resource:///modules/source-editor.jsm");
let tempScope = {};
Cu.import("resource:///modules/source-editor.jsm", tempScope);
let SourceEditor = tempScope.SourceEditor;
let testWin;
let editor;

View File

@ -4,7 +4,9 @@
"use strict";
Cu.import("resource:///modules/source-editor.jsm");
let tempScope = {};
Cu.import("resource:///modules/source-editor.jsm", tempScope);
let SourceEditor = tempScope.SourceEditor;
let testWin;
let editor;

View File

@ -4,7 +4,9 @@
"use strict";
Cu.import("resource:///modules/source-editor.jsm");
let tempScope = {};
Cu.import("resource:///modules/source-editor.jsm", tempScope);
let SourceEditor = tempScope.SourceEditor;
let testWin;
let editor;

View File

@ -4,7 +4,9 @@
"use strict";
Cu.import("resource:///modules/source-editor.jsm");
let tempScope = {};
Cu.import("resource:///modules/source-editor.jsm", tempScope);
let SourceEditor = tempScope.SourceEditor;
let testWin;
let editor;

View File

@ -4,7 +4,9 @@
"use strict";
Cu.import("resource:///modules/source-editor.jsm");
let tempScope = {};
Cu.import("resource:///modules/source-editor.jsm", tempScope);
let SourceEditor = tempScope.SourceEditor;
let testWin;
let editor;

View File

@ -4,7 +4,9 @@
"use strict";
Cu.import("resource:///modules/source-editor.jsm");
let tempScope = {};
Cu.import("resource:///modules/source-editor.jsm", tempScope);
let SourceEditor = tempScope.SourceEditor;
let testWin;
let editor;

View File

@ -4,7 +4,9 @@
"use strict";
Cu.import("resource:///modules/source-editor.jsm");
let tempScope = {};
Cu.import("resource:///modules/source-editor.jsm", tempScope);
let SourceEditor = tempScope.SourceEditor;
let testWin;
let testDoc;

View File

@ -5,7 +5,10 @@
// http rather than chrome to improve coverage
const TESTCASE_URI = TEST_BASE_HTTP + "simple.html";
Components.utils.import("resource://gre/modules/FileUtils.jsm");
let tempScope = {};
Components.utils.import("resource://gre/modules/FileUtils.jsm", tempScope);
let FileUtils = tempScope.FileUtils;
const FILENAME = "styleeditor-import-test.css";
const SOURCE = "body{background:red;}";

View File

@ -7,7 +7,10 @@ const TESTCASE_URI = TEST_BASE_HTTP + "simple.gz.html";
const Cc = Components.classes;
const Ci = Components.interfaces;
Components.utils.import("resource://gre/modules/FileUtils.jsm");
let tempScope = {};
Components.utils.import("resource://gre/modules/FileUtils.jsm", tempScope);
let FileUtils = tempScope.FileUtils;
function test()

View File

@ -14,7 +14,6 @@ function createDocument()
'<span class="matches">Some styled text</span>' +
'</div>';
doc.title = "Style Inspector key binding test";
ok(window.StyleInspector, "StyleInspector exists");
stylePanel = new StyleInspector(window);
Services.obs.addObserver(runStyleInspectorTests, "StyleInspector-opened", false);
stylePanel.createPanel(false, function() {

View File

@ -9,7 +9,10 @@ let stylePanel;
const TEST_URI = "http://example.com/browser/browser/devtools/styleinspector/test/browser_bug683672.html";
Cu.import("resource:///modules/devtools/CssHtmlTree.jsm");
let tempScope = {};
Cu.import("resource:///modules/devtools/CssHtmlTree.jsm", tempScope);
let CssHtmlTree = tempScope.CssHtmlTree;
let PropertyView = tempScope.PropertyView;
function test()
{
@ -22,7 +25,6 @@ function tabLoaded()
{
browser.removeEventListener("load", tabLoaded, true);
doc = content.document;
ok(window.StyleInspector, "StyleInspector exists");
// ok(StyleInspector.isEnabled, "style inspector preference is enabled");
stylePanel = new StyleInspector(window);
Services.obs.addObserver(runTests, "StyleInspector-opened", false);

View File

@ -12,7 +12,6 @@ function createDocument()
doc.body.innerHTML = "<div style='color:blue;'></div>";
doc.title = "Style Inspector Selector Text Test";
ok(window.StyleInspector, "StyleInspector exists");
stylePanel = new StyleInspector(window);

View File

@ -4,7 +4,9 @@
// Test that inherited properties are treated correctly.
Cu.import("resource:///modules/devtools/CssLogic.jsm");
let tempScope = {};
Cu.import("resource:///modules/devtools/CssLogic.jsm", tempScope);
let CssLogic = tempScope.CssLogic;
let doc;

View File

@ -2,7 +2,11 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource:///modules/devtools/CssRuleView.jsm");
let tempScope = {}
Cu.import("resource:///modules/devtools/CssRuleView.jsm", tempScope);
let CssRuleView = tempScope.CssRuleView;
let _ElementStyle = tempScope._ElementStyle;
let _editableField = tempScope._editableField;
let doc = content.document;
@ -118,4 +122,4 @@ function test()
}, true);
content.location = "data:text/html,inline editor tests";
}
}

View File

@ -2,7 +2,11 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource:///modules/devtools/CssRuleView.jsm");
let tempScope = {}
Cu.import("resource:///modules/devtools/CssRuleView.jsm", tempScope);
let CssRuleView = tempScope.CssRuleView;
let _ElementStyle = tempScope._ElementStyle;
let _editableField = tempScope._editableField;
let doc;

View File

@ -2,7 +2,11 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource:///modules/devtools/CssRuleView.jsm");
let tempScope = {}
Cu.import("resource:///modules/devtools/CssRuleView.jsm", tempScope);
let CssRuleView = tempScope.CssRuleView;
let _ElementStyle = tempScope._ElementStyle;
let _editableField = tempScope._editableField;
let doc;

View File

@ -2,7 +2,11 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource:///modules/devtools/CssRuleView.jsm");
let tempScope = {}
Cu.import("resource:///modules/devtools/CssRuleView.jsm", tempScope);
let CssRuleView = tempScope.CssRuleView;
let _ElementStyle = tempScope._ElementStyle;
let _editableField = tempScope._editableField;
let doc;

View File

@ -2,7 +2,11 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource:///modules/devtools/CssRuleView.jsm");
let tempScope = {}
Cu.import("resource:///modules/devtools/CssRuleView.jsm", tempScope);
let CssRuleView = tempScope.CssRuleView;
let _ElementStyle = tempScope._ElementStyle;
let _editableField = tempScope._editableField;
let doc;
let ruleDialog;

View File

@ -26,7 +26,6 @@ function createDocument()
'<p>Inspect using inspectstyle(document.querySelectorAll("span")[0])</p>' +
'</div>';
doc.title = "Style Inspector Test";
ok(window.StyleInspector, "StyleInspector exists");
stylePanel = new StyleInspector(window);
Services.obs.addObserver(runStyleInspectorTests, "StyleInspector-opened", false);
stylePanel.createPanel(false, function() {

View File

@ -14,7 +14,6 @@ function createDocument()
'<span id="matches" class="matches">Some styled text</span>' +
'</div>';
doc.title = "Style Inspector Search Filter Test";
ok(window.StyleInspector, "StyleInspector exists");
// ok(StyleInspector.isEnabled, "style inspector preference is enabled");
stylePanel = new StyleInspector(window);
Services.obs.addObserver(runStyleInspectorTests, "StyleInspector-opened", false);

View File

@ -14,7 +14,6 @@ function createDocument()
'<span id="matches" class="matches">Some styled text</span>' +
'</div>';
doc.title = "Style Inspector Default Styles Test";
ok(window.StyleInspector, "StyleInspector exists");
// ok(StyleInspector.isEnabled, "style inspector preference is enabled");
stylePanel = new StyleInspector(window);
Services.obs.addObserver(runStyleInspectorTests, "StyleInspector-opened", false);

View File

@ -13,7 +13,6 @@ function createDocument()
'.matches {color: #F00;}</style>' +
'<span id="matches" class="matches">Some styled text</span>';
doc.title = "Tests that the no results placeholder works properly";
ok(window.StyleInspector, "StyleInspector exists");
stylePanel = new StyleInspector(window);
Services.obs.addObserver(runStyleInspectorTests, "StyleInspector-opened", false);
stylePanel.createPanel(false, function() {

View File

@ -35,8 +35,12 @@
*
* ***** END LICENSE BLOCK ***** */
Cu.import("resource:///modules/devtools/StyleInspector.jsm");
Cu.import("resource://gre/modules/HUDService.jsm");
let tempScope = {};
Cu.import("resource:///modules/devtools/StyleInspector.jsm", tempScope);
Cu.import("resource://gre/modules/HUDService.jsm", tempScope);
let StyleInspector = tempScope.StyleInspector;
let HUDService = tempScope.HUDService;
let ConsoleUtils = tempScope.ConsoleUtils;
function log(aMsg)
{

View File

@ -5,10 +5,20 @@
/*global InspectorUI, Tilt, TiltGL, EPSILON */
"use strict";
Components.utils.import("resource:///modules/devtools/TiltGL.jsm");
Components.utils.import("resource:///modules/devtools/TiltMath.jsm");
Components.utils.import("resource:///modules/devtools/TiltUtils.jsm");
Components.utils.import("resource:///modules/devtools/TiltVisualizer.jsm");
let tempScope = {};
Components.utils.import("resource:///modules/devtools/TiltGL.jsm", tempScope);
Components.utils.import("resource:///modules/devtools/TiltMath.jsm", tempScope);
Components.utils.import("resource:///modules/devtools/TiltUtils.jsm", tempScope);
Components.utils.import("resource:///modules/devtools/TiltVisualizer.jsm", tempScope);
let TiltGL = tempScope.TiltGL;
let EPSILON = tempScope.EPSILON;
let TiltMath = tempScope.TiltMath;
let vec3 = tempScope.vec3;
let mat3 = tempScope.mat3;
let mat4 = tempScope.mat4;
let quat4 = tempScope.quat4;
let TiltUtils = tempScope.TiltUtils;
let TiltVisualizer = tempScope.TiltVisualizer;
const DEFAULT_HTML = "data:text/html," +

View File

@ -7,7 +7,9 @@
// Tests that the inspect command works as it should
Components.utils.import("resource:///modules/gcli.jsm");
let tempScope = {};
Components.utils.import("resource:///modules/gcli.jsm", tempScope);
let gcli = tempScope.gcli;
registerCleanupFunction(function() {
gcliterm = undefined;

View File

@ -8,7 +8,9 @@
// Tests that source URLs in the Web Console can be clicked to display the
// standard View Source window.
Components.utils.import("resource:///modules/gcli.jsm");
let tempScope = {};
Components.utils.import("resource:///modules/gcli.jsm", tempScope);
let gcli = tempScope.gcli;
let require = gcli._internal.require;
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";

View File

@ -10,8 +10,6 @@
// Tests that appropriately-localized timestamps are printed.
Cu.import("resource:///modules/HUDService.jsm");
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
function test() {

View File

@ -37,6 +37,7 @@
* ***** END LICENSE BLOCK ***** */
const TEST_URI = "data:text/html,<p>bug 585991 - autocomplete popup keyboard usage test";
let HUD;
registerCleanupFunction(function() {
Services.prefs.clearUserPref("devtools.gcli.enable");

View File

@ -72,8 +72,6 @@ function testSelectionWhenMovingBetweenBoxes() {
outputNode.selectedIndex = -1;
commandEvent = contextMenu = groupNode = range = null;
finishTest();
}

View File

@ -17,7 +17,7 @@ function tabLoad(aEvent) {
openConsole();
let hudId = HUDService.getHudIdByWindow(content);
HUD = HUDService.hudReferences[hudId];
let HUD = HUDService.hudReferences[hudId];
inputNode = HUD.jsterm.inputNode;

View File

@ -91,6 +91,7 @@ let inputValues = [
let eventHandlers = [];
let popupShown = [];
let HUD;
function tabLoad(aEvent) {
browser.removeEventListener(aEvent.type, arguments.callee, true);
@ -221,7 +222,6 @@ function testEnd() {
}
}
eventHandlers = popupshown = null;
executeSoon(finishTest);
}

View File

@ -21,7 +21,7 @@ function test() {
function populateConsoleRepeats(aHudRef) {
let hud = aHudRef.HUDBox;
for (i = 0; i < 5; i++) {
for (let i = 0; i < 5; i++) {
let node = ConsoleUtils.createMessageNode(hud.ownerDocument,
CATEGORY_CSS,
SEVERITY_WARNING,
@ -35,7 +35,7 @@ function populateConsoleRepeats(aHudRef) {
function populateConsole(aHudRef) {
let hud = aHudRef.HUDBox;
for (i = 0; i < LOG_LIMIT + 5; i++) {
for (let i = 0; i < LOG_LIMIT + 5; i++) {
let node = ConsoleUtils.createMessageNode(hud.ownerDocument,
CATEGORY_CSS,
SEVERITY_WARNING,

View File

@ -6,7 +6,12 @@
// Tests that document.body autocompletes in the web console.
Cu.import("resource:///modules/PropertyPanel.jsm");
let tempScope = {};
Cu.import("resource:///modules/PropertyPanel.jsm", tempScope);
let PropertyPanel = tempScope.PropertyPanel;
let PropertyTreeView = tempScope.PropertyTreeView;
let namesAndValuesOf = tempScope.namesAndValuesOf;
let isNonNativeGetter = tempScope.isNonNativeGetter;
registerCleanupFunction(function() {
Services.prefs.clearUserPref("devtools.gcli.enable");

View File

@ -36,7 +36,10 @@
*
* ***** END LICENSE BLOCK ***** */
Cu.import("resource:///modules/HUDService.jsm");
let tempScope = {};
Cu.import("resource:///modules/HUDService.jsm", tempScope);
let HUDService = tempScope.HUDService;
let ConsoleUtils = tempScope.ConsoleUtils;
function log(aMsg)
{

View File

@ -104,7 +104,7 @@ function sendString(aStr, aWindow) {
* KeyEvent constant name for this key. No modifiers are handled at this point.
*/
function sendKey(aKey, aWindow) {
keyName = "VK_" + aKey.toUpperCase();
var keyName = "VK_" + aKey.toUpperCase();
synthesizeKey(keyName, { shiftKey: false }, aWindow);
}