From 7d571fe52fc22917b84b619073487b0005a7d930 Mon Sep 17 00:00:00 2001 From: Chung-Sheng Fu Date: Thu, 8 Jun 2017 17:52:46 +0800 Subject: [PATCH] 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 --HG-- extra : rebase_source : b0cf8d159ba6bfa6e7bcd9528ae2f9851185ac30 --- browser/installer/package-manifest.in | 6 +++--- devtools/client/jsonview/converter-child.js | 2 +- devtools/client/jsonview/viewer-config.js | 8 ++++---- devtools/shared/jar.mn | 2 ++ dom/html/ImageDocument.cpp | 4 ++-- dom/html/VideoDocument.cpp | 2 +- dom/xml/resources/XMLPrettyPrint.css | 2 +- layout/style/jar.mn | 2 +- layout/style/moz.build | 4 ++++ mobile/android/installer/package-manifest.in | 5 +++-- parser/html/nsHtml5ViewSourceUtils.cpp | 2 +- python/mozbuild/mozbuild/frontend/context.py | 8 ++++++++ python/mozbuild/mozpack/chrome/manifest.py | 1 + python/mozbuild/mozpack/packager/formats.py | 1 + toolkit/content/browser-content.js | 2 +- 15 files changed, 34 insertions(+), 17 deletions(-) diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index df363b1dfef92..859be7c86c611 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -681,9 +681,6 @@ @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 @@ -715,6 +712,9 @@ @RESPATH@/res/MainMenu.nib/ #endif +; Content-accessible resources. +@RESPATH@/contentaccessible/* + ; svg @RESPATH@/res/svg.css @RESPATH@/components/dom_svg.xpt diff --git a/devtools/client/jsonview/converter-child.js b/devtools/client/jsonview/converter-child.js index d272dad00fb11..19060088ae6b2 100644 --- a/devtools/client/jsonview/converter-child.js +++ b/devtools/client/jsonview/converter-child.js @@ -208,7 +208,7 @@ function initialHTML(doc) { // The base URI is prepended to all URIs instead of using a 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"; diff --git a/devtools/client/jsonview/viewer-config.js b/devtools/client/jsonview/viewer-config.js index 387a0dd4ebfb0..429bf9b07298d 100644 --- a/devtools/client/jsonview/viewer-config.js +++ b/devtools/client/jsonview/viewer-config.js @@ -21,14 +21,14 @@ * 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" } }); diff --git a/devtools/shared/jar.mn b/devtools/shared/jar.mn index 4d0823550c5a5..82dc7741b2131 100644 --- a/devtools/shared/jar.mn +++ b/devtools/shared/jar.mn @@ -4,6 +4,8 @@ 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 diff --git a/dom/html/ImageDocument.cpp b/dom/html/ImageDocument.cpp index b9f8b2d98abfd..5578b544d7638 100644 --- a/dom/html/ImageDocument.cpp +++ b/dom/html/ImageDocument.cpp @@ -279,9 +279,9 @@ ImageDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject) 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")); } } diff --git a/dom/html/VideoDocument.cpp b/dom/html/VideoDocument.cpp index 1bd898564a472..9ca616a5ec536 100644 --- a/dom/html/VideoDocument.cpp +++ b/dom/html/VideoDocument.cpp @@ -74,7 +74,7 @@ VideoDocument::SetScriptGlobalObject(nsIScriptGlobalObject* 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")); } diff --git a/dom/xml/resources/XMLPrettyPrint.css b/dom/xml/resources/XMLPrettyPrint.css index efc7ab5e5e175..13bb61e71532b 100644 --- a/dom/xml/resources/XMLPrettyPrint.css +++ b/dom/xml/resources/XMLPrettyPrint.css @@ -3,7 +3,7 @@ * 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; diff --git a/layout/style/jar.mn b/layout/style/jar.mn index af8c15d4fab57..81af0f7540fc2 100644 --- a/layout/style/jar.mn +++ b/layout/style/jar.mn @@ -7,7 +7,6 @@ toolkit.jar: * 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) @@ -33,3 +32,4 @@ toolkit.jar: 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 diff --git a/layout/style/moz.build b/layout/style/moz.build index 0d1f261454f93..d4fbd0fef3849 100644 --- a/layout/style/moz.build +++ b/layout/style/moz.build @@ -300,7 +300,11 @@ JAR_MANIFESTS += ['jar.mn'] RESOURCE_FILES += [ 'contenteditable.css', 'designmode.css', +] + +CONTENT_ACCESSIBLE_FILES += [ 'ImageDocument.css', + 'res/viewsource.css', 'TopLevelImageDocument.css', 'TopLevelVideoDocument.css', ] diff --git a/mobile/android/installer/package-manifest.in b/mobile/android/installer/package-manifest.in index 70ceb95452df6..2b4dba05fa882 100644 --- a/mobile/android/installer/package-manifest.in +++ b/mobile/android/installer/package-manifest.in @@ -463,8 +463,6 @@ @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 @@ -495,6 +493,9 @@ @BINPATH@/res/fonts/*.properties #endif +; Content-accessible resources. +@BINPATH@/contentaccessible/* + ; svg @BINPATH@/res/svg.css @BINPATH@/components/dom_svg.xpt diff --git a/parser/html/nsHtml5ViewSourceUtils.cpp b/parser/html/nsHtml5ViewSourceUtils.cpp index b2f635bffe52a..d94865d0acee0 100644 --- a/parser/html/nsHtml5ViewSourceUtils.cpp +++ b/parser/html/nsHtml5ViewSourceUtils.cpp @@ -50,7 +50,7 @@ nsHtml5ViewSourceUtils::NewLinkAttributes() 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; } diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py index 3feb7d1666ef8..23c71d0c51bca 100644 --- a/python/mozbuild/mozbuild/frontend/context.py +++ b/python/mozbuild/mozbuild/frontend/context.py @@ -2086,6 +2086,14 @@ def Program(name): 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. diff --git a/python/mozbuild/mozpack/chrome/manifest.py b/python/mozbuild/mozpack/chrome/manifest.py index 71241764da36d..5c5b51f9949cd 100644 --- a/python/mozbuild/mozpack/chrome/manifest.py +++ b/python/mozbuild/mozpack/chrome/manifest.py @@ -38,6 +38,7 @@ class ManifestEntry(object): 'xpcnativewrappers', 'tablet', 'process', + 'contentaccessible', ] def __init__(self, base, *flags): diff --git a/python/mozbuild/mozpack/packager/formats.py b/python/mozbuild/mozpack/packager/formats.py index 3f92fdd242047..f18e46f90145a 100644 --- a/python/mozbuild/mozpack/packager/formats.py +++ b/python/mozbuild/mozpack/packager/formats.py @@ -339,4 +339,5 @@ def is_resource(self, path): 'greprefs.js', 'hyphenation', 'update.locale', + 'contentaccessible', ] diff --git a/toolkit/content/browser-content.js b/toolkit/content/browser-content.js index 7e496dca55387..c5872fd9dd205 100644 --- a/toolkit/content/browser-content.js +++ b/toolkit/content/browser-content.js @@ -1337,7 +1337,7 @@ var ViewSelectionSource = { 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);