Loading toolkit/components/reader/AboutReader.sys.mjs +1 −0 Original line number Diff line number Diff line Loading @@ -788,6 +788,7 @@ AboutReader.prototype = { try { article = await ReaderMode.downloadAndParseDocument( url, { ...this._doc.nodePrincipal?.originAttributes }, docContentType ); } catch (e) { Loading toolkit/components/reader/ReaderMode.sys.mjs +13 −4 Original line number Diff line number Diff line Loading @@ -231,11 +231,12 @@ export var ReaderMode = { * Downloads and parses a document from a URL. * * @param url URL to download and parse. * @param attrs OriginAttributes to use for the request. * @return {Promise} * @resolves JS object representing the article, or null if no article is found. */ async downloadAndParseDocument(url, docContentType = "document") { let result = await this._downloadDocument(url, docContentType); async downloadAndParseDocument(url, attrs = {}, docContentType = "document") { let result = await this._downloadDocument(url, attrs, docContentType); if (!result?.doc) { return null; } Loading @@ -258,9 +259,11 @@ export var ReaderMode = { return article; }, _downloadDocument(url, docContentType = "document") { _downloadDocument(url, attrs = {}, docContentType = "document") { let uri; try { if (!lazy.Readerable.shouldCheckUri(Services.io.newURI(url))) { uri = Services.io.newURI(url); if (!lazy.Readerable.shouldCheckUri(uri)) { return null; } } catch (ex) { Loading @@ -272,9 +275,15 @@ export var ReaderMode = { let histogram = Services.telemetry.getHistogramById( "READER_MODE_DOWNLOAD_RESULT" ); try { attrs.firstPartyDomain = Services.eTLD.getSchemelessSite(uri); } catch (e) { console.error("Failed to get first party domain for about:reader", e); } return new Promise((resolve, reject) => { let xhr = new XMLHttpRequest(); xhr.open("GET", url, true); xhr.setOriginAttributes(attrs); xhr.onerror = evt => reject(evt.error); xhr.responseType = docContentType === "text/plain" ? "text" : "document"; xhr.onload = evt => { Loading Loading
toolkit/components/reader/AboutReader.sys.mjs +1 −0 Original line number Diff line number Diff line Loading @@ -788,6 +788,7 @@ AboutReader.prototype = { try { article = await ReaderMode.downloadAndParseDocument( url, { ...this._doc.nodePrincipal?.originAttributes }, docContentType ); } catch (e) { Loading
toolkit/components/reader/ReaderMode.sys.mjs +13 −4 Original line number Diff line number Diff line Loading @@ -231,11 +231,12 @@ export var ReaderMode = { * Downloads and parses a document from a URL. * * @param url URL to download and parse. * @param attrs OriginAttributes to use for the request. * @return {Promise} * @resolves JS object representing the article, or null if no article is found. */ async downloadAndParseDocument(url, docContentType = "document") { let result = await this._downloadDocument(url, docContentType); async downloadAndParseDocument(url, attrs = {}, docContentType = "document") { let result = await this._downloadDocument(url, attrs, docContentType); if (!result?.doc) { return null; } Loading @@ -258,9 +259,11 @@ export var ReaderMode = { return article; }, _downloadDocument(url, docContentType = "document") { _downloadDocument(url, attrs = {}, docContentType = "document") { let uri; try { if (!lazy.Readerable.shouldCheckUri(Services.io.newURI(url))) { uri = Services.io.newURI(url); if (!lazy.Readerable.shouldCheckUri(uri)) { return null; } } catch (ex) { Loading @@ -272,9 +275,15 @@ export var ReaderMode = { let histogram = Services.telemetry.getHistogramById( "READER_MODE_DOWNLOAD_RESULT" ); try { attrs.firstPartyDomain = Services.eTLD.getSchemelessSite(uri); } catch (e) { console.error("Failed to get first party domain for about:reader", e); } return new Promise((resolve, reject) => { let xhr = new XMLHttpRequest(); xhr.open("GET", url, true); xhr.setOriginAttributes(attrs); xhr.onerror = evt => reject(evt.error); xhr.responseType = docContentType === "text/plain" ? "text" : "document"; xhr.onload = evt => { Loading