Bug 703965 - View source prefs not obeyed in non-HTML documents - tests; r=hsivonen
authorGeoff Lankow <geoff@darktrojan.net>
Thu, 01 Dec 2011 13:09:33 +1300
changeset 81052 81a01033b52d73735cb41f772de628df195ba869
parent 81051 b6d8f601d8659306b85b6828bee0b76ba7211ffb
child 81053 fcba4797331726bb7c0b05ba13676539bf0313db
push id21551
push usermak77@bonardo.net
push dateThu, 01 Dec 2011 11:17:51 +0000
treeherdermozilla-central@66a1db693790 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsivonen
bugs703965
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 703965 - View source prefs not obeyed in non-HTML documents - tests; r=hsivonen
toolkit/components/viewsource/test/browser/Makefile.in
toolkit/components/viewsource/test/browser/browser_viewsourceprefs.js
toolkit/components/viewsource/test/browser/browser_viewsourceprefs_nonhtml.js
--- a/toolkit/components/viewsource/test/browser/Makefile.in
+++ b/toolkit/components/viewsource/test/browser/Makefile.in
@@ -42,13 +42,14 @@ VPATH     = @srcdir@
 relativesrcdir  = toolkit/components/viewsource/test/browser
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _BROWSER_CHROME_FILES   = \
                 browser_bug699356.js \
                 browser_viewsourceprefs.js \
+                browser_viewsourceprefs_nonhtml.js \
                 head.js \
                 $(NULL)
 
 libs:: $(_BROWSER_CHROME_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
--- a/toolkit/components/viewsource/test/browser/browser_viewsourceprefs.js
+++ b/toolkit/components/viewsource/test/browser/browser_viewsourceprefs.js
@@ -4,16 +4,22 @@
 
 let source = "about:robots";
 let mWindow, wrapMenuItem, syntaxMenuItem;
 
 // Check the default values are set.
 function test() {
   waitForExplicitFinish();
 
+  registerCleanupFunction(function() {
+    SpecialPowers.clearUserPref("view_source.tab_size");
+    SpecialPowers.clearUserPref("view_source.wrap_long_lines");
+    SpecialPowers.clearUserPref("view_source.syntax_highlight");
+  });
+
   openViewSourceWindow(source, function(aWindow) {
     mWindow = aWindow;
     wrapMenuItem = aWindow.document.getElementById('menu_wrapLongLines');
     syntaxMenuItem = aWindow.document.getElementById('menu_highlightSyntax');
 
     // Strip checked="false" attributes, since we're not interested in them.
     if (wrapMenuItem.getAttribute("checked") == "false")
       wrapMenuItem.removeAttribute("checked");
@@ -72,21 +78,21 @@ function test4() {
     closeViewSourceWindow(mWindow, test5);
   }, false);
 
   simulateClick(syntaxMenuItem);
 }
 
 // Open a new view-source window to check prefs are obeyed.
 function test5() {
-  SpecialPowers.pushPrefEnv({'set': [
-    ["view_source.tab_size", 2],
-    ["view_source.wrap_long_lines", true],
-    ["view_source.syntax_highlight", false]
-  ]}, function() {
+  SpecialPowers.setIntPref("view_source.tab_size", 2);
+  SpecialPowers.setBoolPref("view_source.wrap_long_lines", true);
+  SpecialPowers.setBoolPref("view_source.syntax_highlight", false);
+
+  executeSoon(function() {
     openViewSourceWindow(source, function(aWindow) {
       wrapMenuItem = aWindow.document.getElementById('menu_wrapLongLines');
       syntaxMenuItem = aWindow.document.getElementById('menu_highlightSyntax');
 
       // Strip checked="false" attributes, since we're not interested in them.
       if (wrapMenuItem.getAttribute("checked") == "false")
         wrapMenuItem.removeAttribute("checked");
       if (syntaxMenuItem.getAttribute("checked") == "false")
copy from toolkit/components/viewsource/test/browser/browser_viewsourceprefs.js
copy to toolkit/components/viewsource/test/browser/browser_viewsourceprefs_nonhtml.js
--- a/toolkit/components/viewsource/test/browser/browser_viewsourceprefs.js
+++ b/toolkit/components/viewsource/test/browser/browser_viewsourceprefs_nonhtml.js
@@ -1,19 +1,25 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
-let source = "about:robots";
+let source = "data:text/plain,hello+world";
 let mWindow, wrapMenuItem, syntaxMenuItem;
 
 // Check the default values are set.
 function test() {
   waitForExplicitFinish();
 
+  registerCleanupFunction(function() {
+    SpecialPowers.clearUserPref("view_source.tab_size");
+    SpecialPowers.clearUserPref("view_source.wrap_long_lines");
+    SpecialPowers.clearUserPref("view_source.syntax_highlight");
+  });
+
   openViewSourceWindow(source, function(aWindow) {
     mWindow = aWindow;
     wrapMenuItem = aWindow.document.getElementById('menu_wrapLongLines');
     syntaxMenuItem = aWindow.document.getElementById('menu_highlightSyntax');
 
     // Strip checked="false" attributes, since we're not interested in them.
     if (wrapMenuItem.getAttribute("checked") == "false")
       wrapMenuItem.removeAttribute("checked");
@@ -63,30 +69,30 @@ function test3() {
 }
 
 function test4() {
   mWindow.gBrowser.addEventListener("pageshow", function test4Handler() {
     mWindow.gBrowser.removeEventListener("pageshow", test4Handler, false);
     is(syntaxMenuItem.hasAttribute("checked"), true, "Syntax menu item checked");
     is(SpecialPowers.getBoolPref("view_source.syntax_highlight"), true, "Syntax highlighting pref set");
 
-    checkHighlight(mWindow, true);
+    checkHighlight(mWindow, false);
     closeViewSourceWindow(mWindow, test5);
   }, false);
 
   simulateClick(syntaxMenuItem);
 }
 
 // Open a new view-source window to check prefs are obeyed.
 function test5() {
-  SpecialPowers.pushPrefEnv({'set': [
-    ["view_source.tab_size", 2],
-    ["view_source.wrap_long_lines", true],
-    ["view_source.syntax_highlight", false]
-  ]}, function() {
+  SpecialPowers.setIntPref("view_source.tab_size", 2);
+  SpecialPowers.setBoolPref("view_source.wrap_long_lines", true);
+  SpecialPowers.setBoolPref("view_source.syntax_highlight", false);
+
+  executeSoon(function() {
     openViewSourceWindow(source, function(aWindow) {
       wrapMenuItem = aWindow.document.getElementById('menu_wrapLongLines');
       syntaxMenuItem = aWindow.document.getElementById('menu_highlightSyntax');
 
       // Strip checked="false" attributes, since we're not interested in them.
       if (wrapMenuItem.getAttribute("checked") == "false")
         wrapMenuItem.removeAttribute("checked");
       if (syntaxMenuItem.getAttribute("checked") == "false")