Bug 1264623 - Allow for a leading slash in the path to web_accessible_resources, r=kmag
authorBob Silverberg <bsilverberg@mozilla.com>
Thu, 14 Apr 2016 09:12:21 -0400
changeset 331672 c3c49869ef0c698e7ed1fab773c71bd7fe1c4975
parent 331671 21a6c80e744da571849aa8f56d8da037ae18c1b4
child 331673 bf3a35b355f0b48ac1020c47198053af9944a493
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1264623
milestone48.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 1264623 - Allow for a leading slash in the path to web_accessible_resources, r=kmag MozReview-Commit-ID: IWbzhs9dpX2
toolkit/components/extensions/Extension.jsm
toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -1159,17 +1159,23 @@ Extension.prototype = extend(Object.crea
     for (let perm of permissions) {
       this.permissions.add(perm);
       if (!/^\w+(\.\w+)*$/.test(perm)) {
         whitelist.push(perm);
       }
     }
     this.whiteListedHosts = new MatchPattern(whitelist);
 
-    this.webAccessibleResources = new MatchGlobs(manifest.web_accessible_resources || []);
+    // Strip leading slashes from web_accessible_resources.
+    let strippedWebAccessibleResources = [];
+    if (manifest.web_accessible_resources) {
+      strippedWebAccessibleResources = manifest.web_accessible_resources.map(path => path.replace(/^\/+/, ""));
+    }
+
+    this.webAccessibleResources = new MatchGlobs(strippedWebAccessibleResources);
 
     for (let directive in manifest) {
       if (manifest[directive] !== null) {
         Management.emit("manifest_" + directive, directive, this, manifest);
       }
     }
 
     let data = Services.ppmm.initialProcessData;
--- a/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html
@@ -91,17 +91,17 @@ add_task(function* test_web_accessible_r
         {
           "matches": ["http://example.com/"],
           "js": ["content_script.js"],
           "run_at": "document_idle",
         },
       ],
 
       "web_accessible_resources": [
-        "accessible.html",
+        "/accessible.html",
         "wild*.html",
       ],
     },
 
     background: `(${background})()`,
 
     files: {
       "content_script.js": `(${contentScript})()`,