Bug 1264623 - Allow for a leading slash in the path to web_accessible_resources, r=kmag

MozReview-Commit-ID: IWbzhs9dpX2

--HG--
extra : transplant_source : j%F5%0E%AAW%F87ijJ%14%26%08%F9%03%96%5Dw%EC%23
This commit is contained in:
Bob Silverberg 2016-04-14 09:12:21 -04:00
parent 633e8d6be7
commit 171756faf0
2 changed files with 8 additions and 2 deletions

View File

@ -1164,7 +1164,13 @@ Extension.prototype = extend(Object.create(ExtensionData.prototype), {
}
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) {

View File

@ -96,7 +96,7 @@ add_task(function* test_web_accessible_resources() {
],
"web_accessible_resources": [
"accessible.html",
"/accessible.html",
"wild*.html",
],
},