Backed out 2 changesets (bug 1245681) for android mochitest-14 failures in test_css_chrome_load_access.html CLOSED TREE
authorWes Kocher <wkocher@mozilla.com>
Fri, 05 Feb 2016 15:16:36 -0800
changeset 283240 8e3f25f37acfe0b3e84f683d43a560bcf2d5dcb4
parent 283239 aa076a770ac03eff1d1f2ba4b0758f22f87acfaf
child 283241 66a1404b99029b76a47a73727d442c4791463cee
push id71480
push userkwierso@gmail.com
push dateFri, 05 Feb 2016 23:17:04 +0000
treeherdermozilla-inbound@8e3f25f37acf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1245681
milestone47.0a1
backs out82803bc92f3772165cedaa29c1d110cc2c6bb9f7
b71df90db19e917b0195c89e76593c8312d2ec68
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
Backed out 2 changesets (bug 1245681) for android mochitest-14 failures in test_css_chrome_load_access.html CLOSED TREE Backed out changeset 82803bc92f37 (bug 1245681) Backed out changeset b71df90db19e (bug 1245681)
editor/libeditor/tests/mochitest.ini
editor/libeditor/tests/test_css_chrome_load_access.html
layout/style/Loader.cpp
--- a/editor/libeditor/tests/mochitest.ini
+++ b/editor/libeditor/tests/mochitest.ini
@@ -162,9 +162,8 @@ 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]
deleted file mode 100644
--- a/editor/libeditor/tests/test_css_chrome_load_access.html
+++ /dev/null
@@ -1,67 +0,0 @@
-<!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>
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -1016,22 +1016,16 @@ Loader::ObsoleteSheet(nsIURI* aURI)
 }
 
 nsresult
 Loader::CheckContentPolicy(nsIPrincipal* aSourcePrincipal,
                           nsIURI* aTargetURI,
                           nsISupports* aContext,
                           bool aIsPreload)
 {
-  // When performing a system load (e.g. aUseSystemPrincipal = true)
-  // then aSourcePrincipal == null; don't consult content policies.
-  if (!aSourcePrincipal) {
-    return NS_OK;
-  }
-
   nsContentPolicyType contentPolicyType =
     aIsPreload ? nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD
                : nsIContentPolicy::TYPE_INTERNAL_STYLESHEET;
 
   int16_t shouldLoad = nsIContentPolicy::ACCEPT;
   nsresult rv = NS_CheckContentLoadPolicy(contentPolicyType,
                                           aTargetURI,
                                           aSourcePrincipal,
@@ -1413,16 +1407,21 @@ Loader::LoadSheet(SheetLoadData* aLoadDa
 
   if (!mDocument && !aLoadData->mIsNonDocumentSheet) {
     // No point starting the load; just release all the data and such.
     LOG_WARN(("  No document and not non-document sheet; pre-dropping load"));
     SheetComplete(aLoadData, NS_BINDING_ABORTED);
     return NS_BINDING_ABORTED;
   }
 
+  nsIPrincipal* triggeringPrincipal = aLoadData->mLoaderPrincipal;
+  if (!triggeringPrincipal) {
+    triggeringPrincipal = nsContentUtils::GetSystemPrincipal();
+  }
+
   SRIMetadata sriMetadata = aLoadData->mSheet->GetIntegrity();
 
   if (aLoadData->mSyncLoad) {
     LOG(("  Synchronous load"));
     NS_ASSERTION(!aLoadData->mObserver, "Observer for a sync load?");
     NS_ASSERTION(aSheetState == eSheetNeedsParser,
                  "Sync loads can't reuse existing async loads");
 
@@ -1453,32 +1452,33 @@ Loader::LoadSheet(SheetLoadData* aLoadDa
 
     // Just load it
     nsCOMPtr<nsIChannel> channel;
     // Note that we are calling NS_NewChannelWithTriggeringPrincipal() with both
     // a node and a principal.
     // This is because of a case where the node is the document being styled and
     // the principal is the stylesheet (perhaps from a different origin) that is
     // applying the styles.
-    if (aLoadData->mRequestingNode && aLoadData->mLoaderPrincipal) {
+    if (aLoadData->mRequestingNode) {
       rv = NS_NewChannelWithTriggeringPrincipal(getter_AddRefs(channel),
                                                 aLoadData->mURI,
                                                 aLoadData->mRequestingNode,
-                                                aLoadData->mLoaderPrincipal,
+                                                triggeringPrincipal,
                                                 securityFlags,
                                                 contentPolicyType);
     }
     else {
       // either we are loading something inside a document, in which case
       // we should always have a requestingNode, or we are loading something
-      // outside a document, in which case the loadingPrincipal and the
-      // triggeringPrincipal should always be the systemPrincipal.
+      // outside a document, in which case the triggeringPrincipal
+      // should always be the systemPrincipal.
+      MOZ_ASSERT(nsContentUtils::IsSystemPrincipal(triggeringPrincipal));
       rv = NS_NewChannel(getter_AddRefs(channel),
                          aLoadData->mURI,
-                         nsContentUtils::GetSystemPrincipal(),
+                         triggeringPrincipal,
                          securityFlags,
                          contentPolicyType);
     }
     if (NS_FAILED(rv)) {
       LOG_ERROR(("  Failed to create channel"));
       SheetComplete(aLoadData, rv);
       return rv;
     }
@@ -1579,36 +1579,37 @@ Loader::LoadSheet(SheetLoadData* aLoadDa
     aIsPreload ? nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD
                : nsIContentPolicy::TYPE_INTERNAL_STYLESHEET;
 
   nsCOMPtr<nsIChannel> channel;
   // Note we are calling NS_NewChannelWithTriggeringPrincipal here with a node
   // and a principal. This is because of a case where the node is the document
   // being styled and the principal is the stylesheet (perhaps from a different
   // origin)  that is applying the styles.
-  if (aLoadData->mRequestingNode && aLoadData->mLoaderPrincipal) {
+  if (aLoadData->mRequestingNode) {
     rv = NS_NewChannelWithTriggeringPrincipal(getter_AddRefs(channel),
                                               aLoadData->mURI,
                                               aLoadData->mRequestingNode,
-                                              aLoadData->mLoaderPrincipal,
+                                              triggeringPrincipal,
                                               securityFlags,
                                               contentPolicyType,
                                               loadGroup,
                                               nullptr,   // aCallbacks
                                               nsIChannel::LOAD_NORMAL |
                                               nsIChannel::LOAD_CLASSIFY_URI);
   }
   else {
     // either we are loading something inside a document, in which case
     // we should always have a requestingNode, or we are loading something
-    // outside a document, in which case the loadingPrincipal and the
-    // triggeringPrincipal should always be the systemPrincipal.
+    // outside a document, in which case the triggeringPrincipal
+    // should always be the systemPrincipal.
+    MOZ_ASSERT(nsContentUtils::IsSystemPrincipal(triggeringPrincipal));
     rv = NS_NewChannel(getter_AddRefs(channel),
                        aLoadData->mURI,
-                       nsContentUtils::GetSystemPrincipal(),
+                       triggeringPrincipal,
                        securityFlags,
                        contentPolicyType,
                        loadGroup,
                        nullptr,   // aCallbacks
                        nsIChannel::LOAD_NORMAL |
                        nsIChannel::LOAD_CLASSIFY_URI);
   }