Created
September 22, 2011 19:42
-
-
Save neonux/1235815 to your computer and use it in GitHub Desktop.
enabled & import fixes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/browser/devtools/styleeditor/test/browser_styleeditor_enabled.js b/browser/devtools/styleeditor/test/browser_styleeditor_enabled.js | |
index f32bf22..4d5b9e3 100644 | |
--- a/browser/devtools/styleeditor/test/browser_styleeditor_enabled.js | |
+++ b/browser/devtools/styleeditor/test/browser_styleeditor_enabled.js | |
@@ -10,11 +10,14 @@ function test() | |
{ | |
waitForExplicitFinish(); | |
+ let count = 0; | |
addTabAndLaunchStyleEditorChromeWhenLoaded(function (aChrome) { | |
aChrome.addChromeListener({ | |
onEditorAdded: function (aChrome, aEditor) { | |
- if (aEditor.styleSheetIndex != 0) { | |
- return; // we want to test against the first stylesheet | |
+ count++; | |
+ if (count != 2) { | |
+ return; // we want to test against the first stylesheet after all | |
+ // stylesheets are loaded | |
} | |
if (!aEditor.sourceEditor) { | |
@@ -47,6 +50,7 @@ function testEnabledToggle(aChrome, aEditor) | |
let firstStyleSheetEditor = aEditor; | |
let firstStyleSheetUI = aChrome.getSummaryElementForEditor(aEditor); | |
+ let enabledToggle = firstStyleSheetUI.querySelector(".stylesheet-enabled"); | |
is(firstStyleSheetEditor.contentDocument.styleSheets[0].disabled, false, | |
"first stylesheet is initially enabled"); | |
@@ -74,7 +78,6 @@ function testEnabledToggle(aChrome, aEditor) | |
"first stylesheet is now disabled, UI has DISABLED class"); | |
// now toggle it back to enabled | |
- let enabledToggle = firstStyleSheetUI.querySelector(".stylesheet-enabled"); | |
EventUtils.synthesizeMouseAtCenter(enabledToggle, {}, gChromeWindow); | |
return; | |
} | |
@@ -93,6 +96,5 @@ function testEnabledToggle(aChrome, aEditor) | |
} | |
}); | |
- let enabledToggle = firstStyleSheetUI.querySelector(".stylesheet-enabled"); | |
EventUtils.synthesizeMouseAtCenter(enabledToggle, {}, gChromeWindow); | |
} | |
diff --git a/browser/devtools/styleeditor/test/browser_styleeditor_import.js b/browser/devtools/styleeditor/test/browser_styleeditor_import.js | |
index f0cfb58..236c1f5 100644 | |
--- a/browser/devtools/styleeditor/test/browser_styleeditor_import.js | |
+++ b/browser/devtools/styleeditor/test/browser_styleeditor_import.js | |
@@ -29,48 +29,46 @@ function test() | |
function run(aChrome) | |
{ | |
- waitForFocus(function () { | |
- is(aChrome.editors.length, 2, | |
- "there is 2 stylesheets initially"); | |
+ executeSoon(function () { | |
+ waitForFocus(function () { | |
+ is(aChrome.editors.length, 2, | |
+ "there is 2 stylesheets initially"); | |
- // create file to import first | |
- let file = FileUtils.getFile("ProfD", [FILENAME]); | |
- let ostream = FileUtils.openSafeFileOutputStream(file); | |
- let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"] | |
- .createInstance(Ci.nsIScriptableUnicodeConverter); | |
- converter.charset = "UTF-8"; | |
- let istream = converter.convertToInputStream(SOURCE); | |
- NetUtil.asyncCopy(istream, ostream, function (status) { | |
- FileUtils.closeSafeFileOutputStream(ostream); | |
+ // create file to import first | |
+ let file = FileUtils.getFile("ProfD", [FILENAME]); | |
+ let ostream = FileUtils.openSafeFileOutputStream(file); | |
+ let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"] | |
+ .createInstance(Ci.nsIScriptableUnicodeConverter); | |
+ converter.charset = "UTF-8"; | |
+ let istream = converter.convertToInputStream(SOURCE); | |
+ NetUtil.asyncCopy(istream, ostream, function (status) { | |
+ FileUtils.closeSafeFileOutputStream(ostream); | |
- // click the import button now that the file to import is ready | |
- waitForFocus(function () { | |
+ // click the import button now that the file to import is ready | |
aChrome._mockImportFile = file; | |
let document = gChromeWindow.document | |
let importButton = document.querySelector(".style-editor-importButton"); | |
EventUtils.synthesizeMouseAtCenter(importButton, {}, gChromeWindow); | |
- }, gChromeWindow); | |
- }); | |
- }, gChromeWindow); | |
+ }); | |
+ }, gChromeWindow); | |
+ }); | |
} | |
function testImported(aChrome, aEditor) | |
{ | |
- waitForFocus(function () { | |
- if (!aEditor.hasFlag("imported")) { | |
- return; | |
- } | |
+ if (!aEditor.hasFlag("imported")) { | |
+ return; | |
+ } | |
- ok(!aEditor.hasFlag("inline"), | |
- "imported stylesheet does not have INLINE flag"); | |
+ ok(!aEditor.hasFlag("inline"), | |
+ "imported stylesheet does not have INLINE flag"); | |
- ok(aEditor.savedFile, | |
- "imported stylesheet will be saved directly into the same file"); | |
+ ok(aEditor.savedFile, | |
+ "imported stylesheet will be saved directly into the same file"); | |
- is(aEditor.getFriendlyName(), FILENAME, | |
- "imported stylesheet has the same name as the filename"); | |
+ is(aEditor.getFriendlyName(), FILENAME, | |
+ "imported stylesheet has the same name as the filename"); | |
- finish(); | |
- }, gChromeWindow); | |
+ finish(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment