Bug 1371453 Part 4: Add a test demonstrating we can handle bad URLs in import rules. draft
authorBrad Werth <bwerth@mozilla.com>
Tue, 27 Jun 2017 11:23:13 -0700
changeset 602088 4a5ad506fd18bf7d1ee5bce2e5900d2866bc32d0
parent 602079 22a19aff23f1cfcb19df9e76e97d31eaed3989d1
child 602089 4a74373281cdb9d67b96f1bb9d95242256b47864
push id66269
push userbwerth@mozilla.com
push dateThu, 29 Jun 2017 16:53:20 +0000
bugs1371453
milestone56.0a1
Bug 1371453 Part 4: Add a test demonstrating we can handle bad URLs in import rules. MozReview-Commit-ID: 60fCVwVeax6
layout/style/test/chrome/chrome.ini
layout/style/test/chrome/test_bug1371453.html
--- a/layout/style/test/chrome/chrome.ini
+++ b/layout/style/test/chrome/chrome.ini
@@ -6,16 +6,17 @@ support-files =
   bug535806-html.html
   bug535806-xul.xul
   hover_helper.html
   match.png
   mismatch.png
 
 [test_author_specified_style.html]
 [test_bug1346623.html]
+[test_bug1371453.html]
 [test_bug418986-2.xul]
 [test_bug1157097.html]
 [test_bug1160724.xul]
 [test_bug535806.xul]
 [test_display_mode.html]
 tags = fullscreen
 [test_display_mode_reflow.html]
 tags = fullscreen
new file mode 100644
--- /dev/null
+++ b/layout/style/test/chrome/test_bug1371453.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Test for Bug 1371453</title>
+<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+<link rel="stylesheet" href="data:text/css,{}">
+<body>
+<script>
+SimpleTest.waitForExplicitFinish();
+
+let DOMUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
+               .getService(SpecialPowers.Ci.inIDOMUtils);
+const Cu = SpecialPowers.Components.utils;
+const { ContentTaskUtils } = Cu.import("resource://testing-common/ContentTaskUtils.jsm", {});
+document.styleSheetChangeEventsEnabled = true;
+
+runTest();
+
+async function runTest() {
+  document.getElementsByTagName("link")[1].sheet.insertRule('@import url("blahblah")', 0);
+
+  // Await and then process the event we expect to arrive.
+  let event = await ContentTaskUtils.waitForEvent(document, "StyleRuleAdded", true);
+  is(event.rule.type, CSSRule.IMPORT_RULE, "Got expected import rule.");
+
+  todo_isnot(event.rule.styleSheet, null, "Import rule contains a stylesheet.");
+
+  let stylo_todo_isnot = SpecialPowers.DOMWindowUtils.isStyledByServo ? todo_isnot : isnot;
+  stylo_todo_isnot(event.rule.media, null, "Import rule contains a media list.");
+
+  is(event.rule.href, "blahblah", "Import rule contains expected href.");
+
+  SimpleTest.finish();
+}
+
+</script>
+</body>
+</html>