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
Родитель a6cc9bf5ed
Коммит f804d5e5eb
47 изменённых файлов: 144 добавлений и 61 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -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,

Просмотреть файл

@ -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()
{

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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()
{

Просмотреть файл

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

Просмотреть файл

@ -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;

Просмотреть файл

@ -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() {

Просмотреть файл

@ -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() {

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;}";

Просмотреть файл

@ -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()

Просмотреть файл

@ -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() {

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;

Просмотреть файл

@ -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";
}
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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() {

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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() {

Просмотреть файл

@ -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)
{

Просмотреть файл

@ -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," +

Просмотреть файл

@ -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;

Просмотреть файл

@ -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";

Просмотреть файл

@ -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() {

Просмотреть файл

@ -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");

Просмотреть файл

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

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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,

Просмотреть файл

@ -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");

Просмотреть файл

@ -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)
{

Просмотреть файл

@ -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);
}