From e5b80e9a8fc116023931fd1bc80d0824b232f108 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 : 888f7ce8f9db809ad5abbe6340af74e9dfb1d73b --- 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 641cc024892f..6c4ae941aef2 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -683,9 +683,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 @@ -716,6 +713,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 d272dad00fb1..19060088ae6b 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 387a0dd4ebfb..429bf9b07298 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 4d0823550c5a..82dc7741b213 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 d5c686c27b9f..6e0d31275a49 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 1bd898564a47..9ca616a5ec53 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 efc7ab5e5e17..13bb61e71532 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 af8c15d4fab5..81af0f7540fc 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 0d1f261454f9..d4fbd0fef384 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 0fc95bb838c8..ebbf39b171b6 100644 --- a/mobile/android/installer/package-manifest.in +++ b/mobile/android/installer/package-manifest.in @@ -459,8 +459,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 @@ -490,6 +488,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 b2f635bffe52..d94865d0acee 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 b06f39e3ee34..e97ee820bc79 100644 --- a/python/mozbuild/mozbuild/frontend/context.py +++ b/python/mozbuild/mozbuild/frontend/context.py @@ -2090,6 +2090,14 @@ SPECIAL_VARIABLES = { 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 0781d0383304..05b97c8b9e09 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 f31d775646a7..ffafd5f520b4 100644 --- a/python/mozbuild/mozpack/packager/formats.py +++ b/python/mozbuild/mozpack/packager/formats.py @@ -340,4 +340,5 @@ class OmniJarSubFormatter(PiecemealFormatter): 'hyphenation', 'localization', 'update.locale', + 'contentaccessible', ] diff --git a/toolkit/content/browser-content.js b/toolkit/content/browser-content.js index 4d2a8fca47a5..f478618c1b5b 100644 --- a/toolkit/content/browser-content.js +++ b/toolkit/content/browser-content.js @@ -1340,7 +1340,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);