From 171756faf0cf5df2b7a790819fcacbf15a9883f9 Mon Sep 17 00:00:00 2001 From: Bob Silverberg Date: Thu, 14 Apr 2016 09:12:21 -0400 Subject: [PATCH] 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 --- toolkit/components/extensions/Extension.jsm | 8 +++++++- .../test/mochitest/test_ext_web_accessible_resources.html | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/toolkit/components/extensions/Extension.jsm b/toolkit/components/extensions/Extension.jsm index 84c870faaf8a..ddab409cce08 100644 --- a/toolkit/components/extensions/Extension.jsm +++ b/toolkit/components/extensions/Extension.jsm @@ -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) { diff --git a/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html b/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html index cf46886a3077..8d83dbd0ca08 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html @@ -96,7 +96,7 @@ add_task(function* test_web_accessible_resources() { ], "web_accessible_resources": [ - "accessible.html", + "/accessible.html", "wild*.html", ], },