Loading toolkit/components/search/OpenSearchEngine.sys.mjs +6 −1 Original line number Original line Diff line number Diff line Loading @@ -144,7 +144,12 @@ export class OpenSearchEngine extends SearchEngine { lazy.logConsole.debug("_install: Downloading engine from:", loadURI.spec); lazy.logConsole.debug("_install: Downloading engine from:", loadURI.spec); var chan = lazy.SearchUtils.makeChannel(loadURI); var chan = lazy.SearchUtils.makeChannel( loadURI, // OpenSearchEngine is loading a definition file for a search engine, // TYPE_DOCUMENT captures that load best Ci.nsIContentPolicy.TYPE_DOCUMENT ); if (this._engineToUpdate && chan instanceof Ci.nsIHttpChannel) { if (this._engineToUpdate && chan instanceof Ci.nsIHttpChannel) { var lastModified = this._engineToUpdate.getAttr("updatelastmodified"); var lastModified = this._engineToUpdate.getAttr("updatelastmodified"); Loading toolkit/components/search/SearchEngine.sys.mjs +4 −1 Original line number Original line Diff line number Diff line Loading @@ -805,7 +805,10 @@ export class SearchEngine { this._hasPreferredIcon = isPreferred; this._hasPreferredIcon = isPreferred; }; }; let chan = lazy.SearchUtils.makeChannel(uri); let chan = lazy.SearchUtils.makeChannel( uri, Ci.nsIContentPolicy.TYPE_IMAGE ); let listener = new lazy.SearchUtils.LoadListener( let listener = new lazy.SearchUtils.LoadListener( chan, chan, /^image\//, /^image\//, Loading toolkit/components/search/SearchUtils.sys.mjs +8 −3 Original line number Original line Diff line number Diff line Loading @@ -248,19 +248,24 @@ export var SearchUtils = { * * * @param {string|nsIURI} url * @param {string|nsIURI} url * The URL string from which to create an nsIChannel. * The URL string from which to create an nsIChannel. * @param {nsIContentPolicy} contentPolicyType * The type of document being loaded. * @returns {nsIChannel} * @returns {nsIChannel} * an nsIChannel object, or null if the url is invalid. * an nsIChannel object, or null if the url is invalid. */ */ makeChannel(url) { makeChannel(url, contentPolicyType) { if (!contentPolicyType) { throw new Error("makeChannel called with invalid content policy type"); } try { try { let uri = typeof url == "string" ? Services.io.newURI(url) : url; let uri = typeof url == "string" ? Services.io.newURI(url) : url; return Services.io.newChannelFromURI( return Services.io.newChannelFromURI( uri, uri, null /* loadingNode */, null /* loadingNode */, Services.scriptSecurityManager.getSystemPrincipal(), Services.scriptSecurityManager.createNullPrincipal({}), null /* triggeringPrincipal */, null /* triggeringPrincipal */, Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL, Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL, Ci.nsIContentPolicy.TYPE_OTHER contentPolicyType ); ); } catch (ex) {} } catch (ex) {} Loading toolkit/components/search/tests/xpcshell/data/iconsRedirect.sjs +1 −1 Original line number Original line Diff line number Diff line Loading @@ -10,7 +10,7 @@ function handleRequest(request, response) { response.setStatusLine("1.1", 302, "Moved"); response.setStatusLine("1.1", 302, "Moved"); if (request.queryString == "type=invalid") { if (request.queryString == "type=invalid") { response.setHeader("Content-Type", "image/png", false); response.setHeader("Content-Type", "image/png", false); response.setHeader("Location", "engine.xml", false); response.setHeader("Location", "/head_search.js", false); } else { } else { response.setHeader("Content-Type", "text/html", false); response.setHeader("Content-Type", "text/html", false); response.setHeader("Location", "remoteIcon.ico", false); response.setHeader("Location", "remoteIcon.ico", false); Loading toolkit/components/search/tests/xpcshell/test_opensearch_icons_invalid.js +4 −1 Original line number Original line Diff line number Diff line Loading @@ -12,9 +12,11 @@ add_task(async function setup() { }); }); add_task(async function test_installedresourceicon() { add_task(async function test_installedresourceicon() { // Attempts to load a resource:// url as an icon. let engine1 = await SearchTestUtils.promiseNewSearchEngine({ let engine1 = await SearchTestUtils.promiseNewSearchEngine({ url: `${gDataUrl}opensearch/resourceicon.xml`, url: `${gDataUrl}opensearch/resourceicon.xml`, }); }); // Attempts to load a chrome:// url as an icon. let engine2 = await SearchTestUtils.promiseNewSearchEngine({ let engine2 = await SearchTestUtils.promiseNewSearchEngine({ url: `${gDataUrl}opensearch/chromeicon.xml`, url: `${gDataUrl}opensearch/chromeicon.xml`, }); }); Loading @@ -32,12 +34,13 @@ add_task(async function test_installedhttpplace() { // The easiest way to test adding the icon is via a generated xml, otherwise // The easiest way to test adding the icon is via a generated xml, otherwise // we have to somehow insert the address of the server into it. // we have to somehow insert the address of the server into it. // Attempts to load a non-image page into an image icon. let engine = await SearchTestUtils.promiseNewSearchEngine({ let engine = await SearchTestUtils.promiseNewSearchEngine({ url: url: `${gDataUrl}data/engineMaker.sjs?` + `${gDataUrl}data/engineMaker.sjs?` + JSON.stringify({ JSON.stringify({ baseURL: gDataUrl, baseURL: gDataUrl, image: "opensearch/resourceicon.xml", image: "head_search.js", name: "invalidicon", name: "invalidicon", method: "GET", method: "GET", }), }), Loading Loading
toolkit/components/search/OpenSearchEngine.sys.mjs +6 −1 Original line number Original line Diff line number Diff line Loading @@ -144,7 +144,12 @@ export class OpenSearchEngine extends SearchEngine { lazy.logConsole.debug("_install: Downloading engine from:", loadURI.spec); lazy.logConsole.debug("_install: Downloading engine from:", loadURI.spec); var chan = lazy.SearchUtils.makeChannel(loadURI); var chan = lazy.SearchUtils.makeChannel( loadURI, // OpenSearchEngine is loading a definition file for a search engine, // TYPE_DOCUMENT captures that load best Ci.nsIContentPolicy.TYPE_DOCUMENT ); if (this._engineToUpdate && chan instanceof Ci.nsIHttpChannel) { if (this._engineToUpdate && chan instanceof Ci.nsIHttpChannel) { var lastModified = this._engineToUpdate.getAttr("updatelastmodified"); var lastModified = this._engineToUpdate.getAttr("updatelastmodified"); Loading
toolkit/components/search/SearchEngine.sys.mjs +4 −1 Original line number Original line Diff line number Diff line Loading @@ -805,7 +805,10 @@ export class SearchEngine { this._hasPreferredIcon = isPreferred; this._hasPreferredIcon = isPreferred; }; }; let chan = lazy.SearchUtils.makeChannel(uri); let chan = lazy.SearchUtils.makeChannel( uri, Ci.nsIContentPolicy.TYPE_IMAGE ); let listener = new lazy.SearchUtils.LoadListener( let listener = new lazy.SearchUtils.LoadListener( chan, chan, /^image\//, /^image\//, Loading
toolkit/components/search/SearchUtils.sys.mjs +8 −3 Original line number Original line Diff line number Diff line Loading @@ -248,19 +248,24 @@ export var SearchUtils = { * * * @param {string|nsIURI} url * @param {string|nsIURI} url * The URL string from which to create an nsIChannel. * The URL string from which to create an nsIChannel. * @param {nsIContentPolicy} contentPolicyType * The type of document being loaded. * @returns {nsIChannel} * @returns {nsIChannel} * an nsIChannel object, or null if the url is invalid. * an nsIChannel object, or null if the url is invalid. */ */ makeChannel(url) { makeChannel(url, contentPolicyType) { if (!contentPolicyType) { throw new Error("makeChannel called with invalid content policy type"); } try { try { let uri = typeof url == "string" ? Services.io.newURI(url) : url; let uri = typeof url == "string" ? Services.io.newURI(url) : url; return Services.io.newChannelFromURI( return Services.io.newChannelFromURI( uri, uri, null /* loadingNode */, null /* loadingNode */, Services.scriptSecurityManager.getSystemPrincipal(), Services.scriptSecurityManager.createNullPrincipal({}), null /* triggeringPrincipal */, null /* triggeringPrincipal */, Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL, Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL, Ci.nsIContentPolicy.TYPE_OTHER contentPolicyType ); ); } catch (ex) {} } catch (ex) {} Loading
toolkit/components/search/tests/xpcshell/data/iconsRedirect.sjs +1 −1 Original line number Original line Diff line number Diff line Loading @@ -10,7 +10,7 @@ function handleRequest(request, response) { response.setStatusLine("1.1", 302, "Moved"); response.setStatusLine("1.1", 302, "Moved"); if (request.queryString == "type=invalid") { if (request.queryString == "type=invalid") { response.setHeader("Content-Type", "image/png", false); response.setHeader("Content-Type", "image/png", false); response.setHeader("Location", "engine.xml", false); response.setHeader("Location", "/head_search.js", false); } else { } else { response.setHeader("Content-Type", "text/html", false); response.setHeader("Content-Type", "text/html", false); response.setHeader("Location", "remoteIcon.ico", false); response.setHeader("Location", "remoteIcon.ico", false); Loading
toolkit/components/search/tests/xpcshell/test_opensearch_icons_invalid.js +4 −1 Original line number Original line Diff line number Diff line Loading @@ -12,9 +12,11 @@ add_task(async function setup() { }); }); add_task(async function test_installedresourceicon() { add_task(async function test_installedresourceicon() { // Attempts to load a resource:// url as an icon. let engine1 = await SearchTestUtils.promiseNewSearchEngine({ let engine1 = await SearchTestUtils.promiseNewSearchEngine({ url: `${gDataUrl}opensearch/resourceicon.xml`, url: `${gDataUrl}opensearch/resourceicon.xml`, }); }); // Attempts to load a chrome:// url as an icon. let engine2 = await SearchTestUtils.promiseNewSearchEngine({ let engine2 = await SearchTestUtils.promiseNewSearchEngine({ url: `${gDataUrl}opensearch/chromeicon.xml`, url: `${gDataUrl}opensearch/chromeicon.xml`, }); }); Loading @@ -32,12 +34,13 @@ add_task(async function test_installedhttpplace() { // The easiest way to test adding the icon is via a generated xml, otherwise // The easiest way to test adding the icon is via a generated xml, otherwise // we have to somehow insert the address of the server into it. // we have to somehow insert the address of the server into it. // Attempts to load a non-image page into an image icon. let engine = await SearchTestUtils.promiseNewSearchEngine({ let engine = await SearchTestUtils.promiseNewSearchEngine({ url: url: `${gDataUrl}data/engineMaker.sjs?` + `${gDataUrl}data/engineMaker.sjs?` + JSON.stringify({ JSON.stringify({ baseURL: gDataUrl, baseURL: gDataUrl, image: "opensearch/resourceicon.xml", image: "head_search.js", name: "invalidicon", name: "invalidicon", method: "GET", method: "GET", }), }), Loading