Bug 1256210 - Part 2: Convert test_additional_sheets.html and test_addSheets.html to mochitest-plain. r?dbaron draft
authorCameron McCormack <cam@mcc.id.au>
Tue, 15 Mar 2016 18:38:08 +1100
changeset 340389 b14b8ff6888a5999da036c024ef7c1860d02d927
parent 340388 3a899da17cdf95b3e57a23690f37e6cc5ac77b69
child 340390 734554eae112b6f60fe700e91c8253d987efbdb4
push id12960
push usercmccormack@mozilla.com
push dateTue, 15 Mar 2016 07:39:57 +0000
reviewersdbaron
bugs1256210
milestone48.0a1
Bug 1256210 - Part 2: Convert test_additional_sheets.html and test_addSheets.html to mochitest-plain. r?dbaron MozReview-Commit-ID: 5YhZBRa3nZQ
layout/style/test/additional_sheets_helper.html
layout/style/test/chrome/additional_sheets_helper.html
layout/style/test/chrome/chrome.ini
layout/style/test/chrome/test_addSheet.html
layout/style/test/chrome/test_additional_sheets.html
layout/style/test/mochitest.ini
layout/style/test/moz.build
layout/style/test/test_addSheet.html
layout/style/test/test_additional_sheets.html
rename from layout/style/test/chrome/additional_sheets_helper.html
rename to layout/style/test/additional_sheets_helper.html
--- a/layout/style/test/chrome/chrome.ini
+++ b/layout/style/test/chrome/chrome.ini
@@ -4,18 +4,16 @@ support-files =
   bug418986-2.js
   bug535806-css.css
   bug535806-html.html
   bug535806-xul.xul
   hover_helper.html
   match.png
   mismatch.png
 
-[test_addSheet.html]
-[test_additional_sheets.html]
 [test_author_specified_style.html]
 [test_bug418986-2.xul]
 [test_bug1157097.html]
 [test_bug1160724.xul]
 [test_bug535806.xul]
 [test_display_mode.html]
 tags = fullscreen
 [test_hover.html]
deleted file mode 100644
--- a/layout/style/test/chrome/test_addSheet.html
+++ /dev/null
@@ -1,46 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for addSheet</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-</head>
-<body onload="run()">
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1024707">Mozilla Bug 1024707</a>
-
-<iframe id="iframe1" src="http://mochi.test:8888/tests/layout/style/test/chrome/additional_sheets_helper.html"></iframe>
-<iframe id="iframe2" src="http://mochi.test:8888/tests/layout/style/test/chrome/additional_sheets_helper.html"></iframe>
-
-<pre id="test">
-<script type="application/javascript; version=1.8">
-const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
-
-let IO = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
-
-let service = Cc["@mozilla.org/content/style-sheet-service;1"]
-                .getService(Ci.nsIStyleSheetService);
-
-function test(win, sheet) {
-    let cs = win.getComputedStyle(win.document.body, null);
-    is(cs.getPropertyValue('color'), "rgb(0, 0, 0)", "should have default color");
-    var windowUtils = win.QueryInterface(Ci.nsIInterfaceRequestor)
-                         .getInterface(Ci.nsIDOMWindowUtils);
-    windowUtils.addSheet(sheet, Ci.nsIDOMWindowUtils.USER_SHEET);
-    is(cs.getPropertyValue('color'), "rgb(255, 0, 0)", "should have changed color to red");
-}
-
-function run() {
-    var uri = IO.newURI("data:text/css,body{color:red;}", null, null);
-    let sheet = service.preloadSheet(uri, Ci.nsIStyleSheetService.USER_SHEET);
-
-    test(document.getElementById("iframe1").contentWindow, sheet);
-    test(document.getElementById("iframe2").contentWindow, sheet);
-
-    SimpleTest.finish();
-}
-
-SimpleTest.waitForExplicitFinish();
-</script>
-</body>
-</html>
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -31,16 +31,20 @@ support-files =
   visited_image_loading_frame.html
   visited_image_loading.sjs
   visited-lying-inner.html
   visited-pref-iframe.html
   xbl_bindings.xml
 generated-files = css_properties.js
 
 [test_acid3_test46.html]
+[test_addSheet.html]
+support-files = additional_sheets_helper.html
+[test_additional_sheets.html]
+support-files = additional_sheets_helper.html
 [test_all_shorthand.html]
 [test_animations.html]
 skip-if = toolkit == 'android'
 [test_animations_async_tests.html]
 support-files = ../../reftests/fonts/Ahem.ttf file_animations_async_tests.html
 [test_animations_dynamic_changes.html]
 [test_animations_effect_timing_duration.html]
 support-files = file_animations_effect_timing_duration.html
--- a/layout/style/test/moz.build
+++ b/layout/style/test/moz.build
@@ -13,17 +13,16 @@ HostSimplePrograms([
 MOCHITEST_MANIFESTS += [
     'mochitest.ini',
 ]
 XPCSHELL_TESTS_MANIFESTS += ['xpcshell.ini']
 BROWSER_CHROME_MANIFESTS += ['browser.ini']
 MOCHITEST_CHROME_MANIFESTS += ['chrome/chrome.ini']
 
 TEST_HARNESS_FILES.testing.mochitest.tests.layout.style.test.chrome += [
-    'chrome/additional_sheets_helper.html',
     'chrome/moz_document_helper.html',
 ]
 
 TEST_HARNESS_FILES.testing.mochitest.tests.layout.style.test['css-visited'] += [
     '/layout/reftests/css-visited/border-1-ref.html',
     '/layout/reftests/css-visited/border-1.html',
     '/layout/reftests/css-visited/border-2-ref.html',
     '/layout/reftests/css-visited/border-2a.html',
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_addSheet.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for addSheet</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body onload="run()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1024707">Mozilla Bug 1024707</a>
+
+<iframe id="iframe1" src="additional_sheets_helper.html"></iframe>
+<iframe id="iframe2" src="additional_sheets_helper.html"></iframe>
+
+<pre id="test">
+<script type="application/javascript; version=1.8">
+
+let gIOService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
+  .getService(SpecialPowers.Ci.nsIIOService);
+
+let gSSService = SpecialPowers.Cc["@mozilla.org/content/style-sheet-service;1"]
+  .getService(SpecialPowers.Ci.nsIStyleSheetService);
+
+function test(win, sheet) {
+    let cs = win.getComputedStyle(win.document.body, null);
+    is(cs.getPropertyValue('color'), "rgb(0, 0, 0)", "should have default color");
+    var windowUtils = SpecialPowers.wrap(win)
+      .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
+      .getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
+    windowUtils.addSheet(sheet, SpecialPowers.Ci.nsIDOMWindowUtils.USER_SHEET);
+    is(cs.getPropertyValue('color'), "rgb(255, 0, 0)", "should have changed color to red");
+}
+
+function run() {
+    var uri = gIOService.newURI("data:text/css,body{color:red;}", null, null);
+    let sheet = gSSService.preloadSheet(uri, SpecialPowers.Ci.nsIStyleSheetService.USER_SHEET);
+
+    test(document.getElementById("iframe1").contentWindow, sheet);
+    test(document.getElementById("iframe2").contentWindow, sheet);
+
+    SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+</script>
+</body>
+</html>
rename from layout/style/test/chrome/test_additional_sheets.html
rename to layout/style/test/test_additional_sheets.html
--- a/layout/style/test/chrome/test_additional_sheets.html
+++ b/layout/style/test/test_additional_sheets.html
@@ -1,29 +1,26 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test for additional sheets</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body onload="run()">
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=737003">Mozilla Bug 737003</a>
-<iframe id="iframe" src="http://mochi.test:8888/tests/layout/style/test/chrome/additional_sheets_helper.html"></iframe>
+<iframe id="iframe" src="additional_sheets_helper.html"></iframe>
 <pre id="test">
 <script type="application/javascript; version=1.8">
 
-
+var gIOService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
+  .getService(SpecialPowers.Ci.nsIIOService)
 
-var gIOService = Components.classes["@mozilla.org/network/io-service;1"]
-  .getService(Components.interfaces.nsIIOService)
-
-var gSSService = Components.classes["@mozilla.org/content/style-sheet-service;1"]
-    .getService(Components.interfaces.nsIStyleSheetService);
+var gSSService = SpecialPowers.Cc["@mozilla.org/content/style-sheet-service;1"]
+  .getService(SpecialPowers.Ci.nsIStyleSheetService);
 
 function getUri(style)
 {
   return "data:text/css," + style;
 }
 
 function getStyle(color, swapped)
 {
@@ -59,26 +56,28 @@ function removeAgentSheet(win, style)
 function removeAuthorSheet(win, style)
 {
   removeSheet(win, style, "AUTHOR_SHEET");
 }
 
 function loadSheet(win, style, type)
 {
   var uri = gIOService.newURI(getUri(style), null, null);
-  var windowUtils = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-    .getInterface(Components.interfaces.nsIDOMWindowUtils);
+  var windowUtils = SpecialPowers.wrap(win)
+    .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
+    .getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
   windowUtils.loadSheet(uri, windowUtils[type]);
 }
 
 function removeSheet(win, style, type)
 {
   var uri = gIOService.newURI(getUri(style), null, null);
-  var windowUtils = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-    .getInterface(Components.interfaces.nsIDOMWindowUtils);
+  var windowUtils = SpecialPowers.wrap(win)
+    .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
+    .getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
   windowUtils.removeSheet(uri, windowUtils[type]);
 }
 
 function loadAndRegisterUserSheet(win, style)
 {
   loadAndRegisterSheet(win, style, "USER_SHEET");
 }