Bug 863246 - Move resources that need to be exposed to web content to locations that are marked as contentaccessible r=billm
authorChung-Sheng Fu <cfu@mozilla.com>
Thu, 08 Jun 2017 17:52:46 +0800
changeset 377248 ac41228312b850e5ee20936dfb1c1236788e7ec9
parent 377247 a676a11885728e790fc81eebb60b8f574ff100d6
child 377249 b9baf84bb1db7fc5da247707cbe3fbe3357b0ea5
push id32405
push userkwierso@gmail.com
push dateTue, 29 Aug 2017 00:39:06 +0000
treeherdermozilla-central@1b4c59eef820 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs863246
milestone57.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 863246 - Move resources that need to be exposed to web content to locations that are marked as contentaccessible r=billm MozReview-Commit-ID: ArhSHKPYOr8
browser/installer/package-manifest.in
devtools/client/jsonview/converter-child.js
devtools/client/jsonview/viewer-config.js
devtools/shared/jar.mn
dom/html/ImageDocument.cpp
dom/html/VideoDocument.cpp
dom/xml/resources/XMLPrettyPrint.css
layout/style/jar.mn
layout/style/moz.build
mobile/android/installer/package-manifest.in
parser/html/nsHtml5ViewSourceUtils.cpp
python/mozbuild/mozbuild/frontend/context.py
python/mozbuild/mozpack/chrome/manifest.py
python/mozbuild/mozpack/packager/formats.py
toolkit/content/browser-content.js
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -678,19 +678,16 @@
 ; Services (gre) prefs
 @RESPATH@/defaults/pref/services-sync.js
 
 ; [Layout Engine Resources]
 ; Style Sheets, Graphics and other Resources used by the layout engine.
 @RESPATH@/res/EditorOverride.css
 @RESPATH@/res/contenteditable.css
 @RESPATH@/res/designmode.css
-@RESPATH@/res/ImageDocument.css
-@RESPATH@/res/TopLevelImageDocument.css
-@RESPATH@/res/TopLevelVideoDocument.css
 @RESPATH@/res/table-add-column-after-active.gif
 @RESPATH@/res/table-add-column-after-hover.gif
 @RESPATH@/res/table-add-column-after.gif
 @RESPATH@/res/table-add-column-before-active.gif
 @RESPATH@/res/table-add-column-before-hover.gif
 @RESPATH@/res/table-add-column-before.gif
 @RESPATH@/res/table-add-row-after-active.gif
 @RESPATH@/res/table-add-row-after-hover.gif
@@ -711,16 +708,19 @@
 @RESPATH@/res/fonts/*
 @RESPATH@/res/dtd/*
 @RESPATH@/res/html/*
 @RESPATH@/res/language.properties
 #ifdef XP_MACOSX
 @RESPATH@/res/MainMenu.nib/
 #endif
 
+; Content-accessible resources.
+@RESPATH@/contentaccessible/*
+
 ; svg
 @RESPATH@/res/svg.css
 @RESPATH@/components/dom_svg.xpt
 @RESPATH@/components/dom_smil.xpt
 
 ; [Personal Security Manager]
 ;
 ; NSS libraries are signed in the staging directory,
--- a/devtools/client/jsonview/converter-child.js
+++ b/devtools/client/jsonview/converter-child.js
@@ -203,17 +203,17 @@ function initialHTML(doc) {
   } else if (platform.startsWith("Darwin")) {
     os = "mac";
   } else {
     os = "linux";
   }
 
   // The base URI is prepended to all URIs instead of using a <base> element
   // because the latter can be blocked by a CSP base-uri directive (bug 1316393)
-  let baseURI = "resource://devtools/client/jsonview/";
+  let baseURI = "resource://devtools-client-jsonview/";
 
   let style = doc.createElement("link");
   style.rel = "stylesheet";
   style.type = "text/css";
   style.href = baseURI + "css/main.css";
 
   let script = doc.createElement("script");
   script.src = baseURI + "lib/require.js";
--- a/devtools/client/jsonview/viewer-config.js
+++ b/devtools/client/jsonview/viewer-config.js
@@ -16,21 +16,21 @@
  * In order to use the developer version you need to specify the following
  * in your .mozconfig (see also bug 1181646):
  * ac_add_options --enable-debug-js-modules
  *
  * React module ID is using exactly the same (relative) path as the rest
  * of the code base, so it's consistent and modules can be easily reused.
  */
 require.config({
-  baseUrl: "resource://devtools/client/jsonview/",
+  baseUrl: "resource://devtools-client-jsonview/",
   paths: {
-    "devtools/client/shared": "resource://devtools/client/shared",
+    "devtools/client/shared": "resource://devtools-client-shared",
     "devtools/shared": "resource://devtools/shared",
     "devtools/client/shared/vendor/react":
       JSONView.debug
-      ? "resource://devtools/client/shared/vendor/react-dev"
-      : "resource://devtools/client/shared/vendor/react"
+      ? "resource://devtools-client-shared/vendor/react-dev"
+      : "resource://devtools-client-shared/vendor/react"
   }
 });
 
 // Load the main panel module
 requirejs(["json-viewer"]);
--- a/devtools/shared/jar.mn
+++ b/devtools/shared/jar.mn
@@ -1,10 +1,12 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 devtools.jar:
 %   resource devtools %modules/devtools/
+%   resource devtools-client-jsonview resource://devtools/client/jsonview/ contentaccessible=yes
+%   resource devtools-client-shared resource://devtools/client/shared/ contentaccessible=yes
 # The typical approach would be to list all the resource files in this manifest
 # for installation.  Instead of doing this, use the DevToolsModules syntax via
 # moz.build files to do the installation so that we can enforce correct paths
 # based on source tree location.
--- a/dom/html/ImageDocument.cpp
+++ b/dom/html/ImageDocument.cpp
@@ -274,19 +274,19 @@ ImageDocument::SetScriptGlobalObject(nsI
       target->AddEventListener(NS_LITERAL_STRING("click"), this, false);
     }
 
     target = do_QueryInterface(aScriptGlobalObject);
     target->AddEventListener(NS_LITERAL_STRING("resize"), this, false);
     target->AddEventListener(NS_LITERAL_STRING("keypress"), this, false);
 
     if (GetReadyStateEnum() != nsIDocument::READYSTATE_COMPLETE) {
-      LinkStylesheet(NS_LITERAL_STRING("resource://gre/res/ImageDocument.css"));
+      LinkStylesheet(NS_LITERAL_STRING("resource://content-accessible/ImageDocument.css"));
       if (!nsContentUtils::IsChildOfSameType(this)) {
-        LinkStylesheet(NS_LITERAL_STRING("resource://gre/res/TopLevelImageDocument.css"));
+        LinkStylesheet(NS_LITERAL_STRING("resource://content-accessible/TopLevelImageDocument.css"));
         LinkStylesheet(NS_LITERAL_STRING("chrome://global/skin/media/TopLevelImageDocument.css"));
       }
     }
     BecomeInteractive();
   }
 }
 
 void
--- a/dom/html/VideoDocument.cpp
+++ b/dom/html/VideoDocument.cpp
@@ -69,17 +69,17 @@ VideoDocument::SetScriptGlobalObject(nsI
 {
   // Set the script global object on the superclass before doing
   // anything that might require it....
   MediaDocument::SetScriptGlobalObject(aScriptGlobalObject);
 
   if (aScriptGlobalObject) {
     if (!nsContentUtils::IsChildOfSameType(this) &&
         GetReadyStateEnum() != nsIDocument::READYSTATE_COMPLETE) {
-      LinkStylesheet(NS_LITERAL_STRING("resource://gre/res/TopLevelVideoDocument.css"));
+      LinkStylesheet(NS_LITERAL_STRING("resource://content-accessible/TopLevelVideoDocument.css"));
       LinkStylesheet(NS_LITERAL_STRING("chrome://global/skin/media/TopLevelVideoDocument.css"));
       LinkScript(NS_LITERAL_STRING("chrome://global/content/TopLevelVideoDocument.js"));
     }
     BecomeInteractive();
   }
 }
 
 nsresult
--- a/dom/xml/resources/XMLPrettyPrint.css
+++ b/dom/xml/resources/XMLPrettyPrint.css
@@ -1,14 +1,14 @@
 @charset "UTF-8";
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-@import url("resource://gre-resources/viewsource.css");
+@import url("resource://content-accessible/viewsource.css");
 
 #header {
   background-color: #ccc;
   border-bottom: 3px solid black;
   padding: 0.5em;
   margin-bottom: 1em;
 }
 
--- a/layout/style/jar.mn
+++ b/layout/style/jar.mn
@@ -2,17 +2,16 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 toolkit.jar:
 *  res/ua.css                                (res/ua.css)
 *  res/html.css                              (res/html.css)
    res/quirk.css                             (res/quirk.css)
    res/plaintext.css                         (res/plaintext.css)
-   res/viewsource.css                        (res/viewsource.css)
    res/counterstyles.css                     (res/counterstyles.css)
    res/noscript.css                          (res/noscript.css)
    res/noframes.css                          (res/noframes.css)
 *  res/forms.css                             (res/forms.css)
    res/number-control.css                    (res/number-control.css)
    res/arrow.gif                             (res/arrow.gif)
    res/arrow-left.gif                        (res/arrow-left.gif)
    res/arrow-right.gif                       (res/arrow-right.gif)
@@ -28,8 +27,9 @@ toolkit.jar:
    res/accessiblecaret-tilt-left@2x.png      (res/accessiblecaret-tilt-left@2x.png)
    res/accessiblecaret-tilt-left@2.25x.png   (res/accessiblecaret-tilt-left@2.25x.png)
    res/accessiblecaret-tilt-right@1x.png     (res/accessiblecaret-tilt-right@1x.png)
    res/accessiblecaret-tilt-right@1.5x.png   (res/accessiblecaret-tilt-right@1.5x.png)
    res/accessiblecaret-tilt-right@2x.png     (res/accessiblecaret-tilt-right@2x.png)
    res/accessiblecaret-tilt-right@2.25x.png  (res/accessiblecaret-tilt-right@2.25x.png)
 
 % resource gre-resources %res/
+% resource content-accessible resource://gre/contentaccessible/ contentaccessible=yes
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -295,17 +295,21 @@ LOCAL_INCLUDES += [
     '/image',
 ]
 
 JAR_MANIFESTS += ['jar.mn']
 
 RESOURCE_FILES += [
     'contenteditable.css',
     'designmode.css',
+]
+
+CONTENT_ACCESSIBLE_FILES += [
     'ImageDocument.css',
+    'res/viewsource.css',
     'TopLevelImageDocument.css',
     'TopLevelVideoDocument.css',
 ]
 
 GENERATED_FILES += [
     'nsStyleStructList.h',
 ]
 
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -454,18 +454,16 @@
 @BINPATH@/greprefs.js
 @BINPATH@/defaults/autoconfig/prefcalls.js
 
 ; [Layout Engine Resources]
 ; Style Sheets, Graphics and other Resources used by the layout engine.
 @BINPATH@/res/EditorOverride.css
 @BINPATH@/res/contenteditable.css
 @BINPATH@/res/designmode.css
-@BINPATH@/res/TopLevelImageDocument.css
-@BINPATH@/res/TopLevelVideoDocument.css
 @BINPATH@/res/table-add-column-after-active.gif
 @BINPATH@/res/table-add-column-after-hover.gif
 @BINPATH@/res/table-add-column-after.gif
 @BINPATH@/res/table-add-column-before-active.gif
 @BINPATH@/res/table-add-column-before-hover.gif
 @BINPATH@/res/table-add-column-before.gif
 @BINPATH@/res/table-add-row-after-active.gif
 @BINPATH@/res/table-add-row-after-hover.gif
@@ -485,16 +483,19 @@
 @BINPATH@/res/language.properties
 
 #ifndef MOZ_ANDROID_EXCLUDE_FONTS
 @BINPATH@/res/fonts/*
 #else
 @BINPATH@/res/fonts/*.properties
 #endif
 
+; Content-accessible resources.
+@BINPATH@/contentaccessible/*
+
 ; svg
 @BINPATH@/res/svg.css
 @BINPATH@/components/dom_svg.xpt
 @BINPATH@/components/dom_smil.xpt
 
 ; [Personal Security Manager]
 ;
 @BINPATH@/components/pipnss.xpt
--- a/parser/html/nsHtml5ViewSourceUtils.cpp
+++ b/parser/html/nsHtml5ViewSourceUtils.cpp
@@ -45,12 +45,12 @@ nsHtml5HtmlAttributes*
 nsHtml5ViewSourceUtils::NewLinkAttributes()
 {
   nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0);
   nsHtml5String rel = nsHtml5Portability::newStringFromLiteral("stylesheet");
   linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel, -1);
   nsHtml5String type = nsHtml5Portability::newStringFromLiteral("text/css");
   linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type, -1);
   nsHtml5String href = nsHtml5Portability::newStringFromLiteral(
-    "resource://gre-resources/viewsource.css");
+    "resource://content-accessible/viewsource.css");
   linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href, -1);
   return linkAttrs;
 }
--- a/python/mozbuild/mozbuild/frontend/context.py
+++ b/python/mozbuild/mozbuild/frontend/context.py
@@ -2085,16 +2085,24 @@ SPECIAL_VARIABLES = {
         subdirectory they should be exported to. For example, to export
         ``foo.res`` to the top-level directory, and ``bar.res`` to ``fonts/``,
         append to ``RESOURCE_FILES`` like so::
 
            RESOURCE_FILES += ['foo.res']
            RESOURCE_FILES.fonts += ['bar.res']
         """),
 
+    'CONTENT_ACCESSIBLE_FILES': (lambda context: context['FINAL_TARGET_FILES'].contentaccessible, list,
+        """List of files which can be accessed by web content through resource:// URIs.
+
+        ``CONTENT_ACCESSIBLE_FILES`` is used to list the files to be exported
+        to ``dist/bin/contentaccessible``. Files can also be appended to a
+        field to indicate which subdirectory they should be exported to.
+        """),
+
     'EXTRA_JS_MODULES': (lambda context: context['FINAL_TARGET_FILES'].modules, list,
         """Additional JavaScript files to distribute.
 
         This variable contains a list of files to copy into
         ``$(FINAL_TARGET)/modules.
         """),
 
     'EXTRA_PP_JS_MODULES': (lambda context: context['FINAL_TARGET_PP_FILES'].modules, list,
--- a/python/mozbuild/mozpack/chrome/manifest.py
+++ b/python/mozbuild/mozpack/chrome/manifest.py
@@ -33,16 +33,17 @@ class ManifestEntry(object):
         'application',
         'platformversion',
         'os',
         'osversion',
         'abi',
         'xpcnativewrappers',
         'tablet',
         'process',
+        'contentaccessible',
     ]
 
     def __init__(self, base, *flags):
         '''
         Initialize a manifest entry with the given base path and flags.
         '''
         self.base = base
         self.flags = Flags(*flags)
--- a/python/mozbuild/mozpack/packager/formats.py
+++ b/python/mozbuild/mozpack/packager/formats.py
@@ -335,9 +335,10 @@ class OmniJarSubFormatter(PiecemealForma
                 not (path[2] == 'channel-prefs.js' and
                      path[1] in ['pref', 'preferences'])
         return path[0] in [
             'modules',
             'greprefs.js',
             'hyphenation',
             'localization',
             'update.locale',
+            'contentaccessible',
         ]
--- a/toolkit/content/browser-content.js
+++ b/toolkit/content/browser-content.js
@@ -1335,17 +1335,17 @@ var ViewSelectionSource = {
     var topNode = this._targetNode;
     while (topNode && topNode.localName != topTag) {
       topNode = topNode.parentNode;
     }
     if (!topNode)
       return undefined;
 
     // serialize
-    const VIEW_SOURCE_CSS = "resource://gre-resources/viewsource.css";
+    const VIEW_SOURCE_CSS = "resource://content-accessible/viewsource.css";
     const BUNDLE_URL = "chrome://global/locale/viewSource.properties";
 
     let bundle = Services.strings.createBundle(BUNDLE_URL);
     var title = bundle.GetStringFromName("viewMathMLSourceTitle");
     var wrapClass = this.wrapLongLines ? ' class="wrap"' : "";
     var source =
       "<!DOCTYPE html>"
     + "<html>"