Bug 1245681 - Test addOverrideStyleSheet (r=bz)
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Fri, 05 Feb 2016 15:28:18 -0800
changeset 283241 66a1404b99029b76a47a73727d442c4791463cee
parent 283240 8e3f25f37acfe0b3e84f683d43a560bcf2d5dcb4
child 283242 9535c05d50222833dd85624148b4d4db563ceca3
push id71481
push userkwierso@gmail.com
push dateFri, 05 Feb 2016 23:38:51 +0000
treeherdermozilla-inbound@66a1404b9902 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1245681
milestone47.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 1245681 - Test addOverrideStyleSheet (r=bz) CLOSED TREE
editor/libeditor/tests/mochitest.ini
editor/libeditor/tests/test_css_chrome_load_access.html
--- a/editor/libeditor/tests/mochitest.ini
+++ b/editor/libeditor/tests/mochitest.ini
@@ -162,8 +162,10 @@ skip-if = toolkit == 'android' # bug 105
 skip-if = toolkit == 'android'
 [test_bug1068979.html]
 [test_bug1109465.html]
 [test_bug1162952.html]
 [test_bug1186799.html]
 [test_bug1181130-1.html]
 [test_bug1181130-2.html]
 [test_backspace_vs.html]
+[test_css_chrome_load_access.html]
+skip-if = toolkit == 'android' # chrome urls not available due to packaging
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/tests/test_css_chrome_load_access.html
@@ -0,0 +1,67 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1245681
+-->
+<head>
+  <title>Test for Bug 1245681</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1245681">Mozilla Bug 1245681</a>
+<p id="display"></p>
+<div id="content">
+  <iframe></iframe>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+const Ci = SpecialPowers.Ci;
+var styleSheets = null;
+
+function runTest() {
+
+  var editframe = window.frames[0];
+  var editdoc = editframe.document;
+  editdoc.designMode = 'on';
+  var editor = SpecialPowers.wrap(editframe)
+                            .QueryInterface(Ci.nsIInterfaceRequestor)
+                            .getInterface(Ci.nsIWebNavigation)
+                            .QueryInterface(Ci.nsIInterfaceRequestor)
+                            .getInterface(Ci.nsIEditingSession)
+                            .getEditorForWindow(editframe);
+
+  styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets);
+
+  // test 1: try to access chrome:// url that is accessible to content
+  try
+  {
+    styleSheets.addOverrideStyleSheet("chrome://browser/content/pageinfo/pageInfo.css");
+    ok(true, "should be allowed to access chrome://*.css if contentaccessible");
+  }
+  catch (ex) {
+    ok(false, "should be allowed to access chrome://*.css if contentaccessible");
+  }
+
+  // test 2: try to access chrome:// url that is *not* accessible to content
+  // please note that addOverrideStyleSheet() is triggered by the system,
+  // so the load should also *always* succeed.
+  try
+  {
+    styleSheets.addOverrideStyleSheet("chrome://mozapps/skin/aboutNetworking.css");
+    ok(true, "should be allowed to access chrome://*.css even if *not* contentaccessible");
+  }
+  catch (ex) {
+    ok(false, "should be allowed to access chrome://*.css even if *not* contentaccessible");
+  }
+  SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(runTest);
+
+</script>
+</pre>
+</body>
+</html>