Bug 1256210 - Part 2: Convert test_additional_sheets.html and test_addSheets.html to mochitest-plain. r=dbaron

--HG--
rename : layout/style/test/chrome/additional_sheets_helper.html => layout/style/test/additional_sheets_helper.html
rename : layout/style/test/chrome/test_addSheet.html => layout/style/test/test_addSheet.html
rename : layout/style/test/chrome/test_additional_sheets.html => layout/style/test/test_additional_sheets.html
This commit is contained in:
Cameron McCormack 2016-03-17 13:17:10 +11:00
Родитель 69e11e6d9e
Коммит 3f7c51c2ae
7 изменённых файлов: 63 добавлений и 63 удалений

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

@ -9,8 +9,6 @@ support-files =
match.png
mismatch.png
[test_addSheet.html]
[test_additional_sheets.html]
[test_author_specified_style.html]
[test_bug418986-2.xul]
[test_bug1157097.html]

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

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

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

@ -34,6 +34,10 @@ support-files =
xbl_bindings.xml
[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'

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

@ -33,7 +33,6 @@ 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',
]

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

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

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

@ -2,23 +2,20 @@
<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)
{
@ -64,16 +61,18 @@ function removeAuthorSheet(win, style)
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]);
}