Loading browser/base/content/pageinfo/pageInfo.js +20 −90 Original line number Diff line number Diff line Loading @@ -281,42 +281,6 @@ function getClipboardHelper() { } const gClipboardHelper = getClipboardHelper(); // namespaces, don't need all of these yet... const XLinkNS = "http://www.w3.org/1999/xlink"; const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; const XMLNS = "http://www.w3.org/XML/1998/namespace"; const XHTMLNS = "http://www.w3.org/1999/xhtml"; const XHTML2NS = "http://www.w3.org/2002/06/xhtml2"; const XHTMLNSre = "^http://www.w3.org/1999/xhtml$"; const XHTML2NSre = "^http://www.w3.org/2002/06/xhtml2$"; const XHTMLre = RegExp(XHTMLNSre + "|" + XHTML2NSre, ""); /* Overlays register functions here. * These arrays are used to hold callbacks that Page Info will call at * various stages. Use them by simply appending a function to them. * For example, add a function to onLoadRegistry by invoking * "onLoadRegistry.push(XXXLoadFunc);" * The XXXLoadFunc should be unique to the overlay module, and will be * invoked as "XXXLoadFunc();" */ // These functions are called to build the data displayed in the Page Info window. var onLoadRegistry = []; // These functions are called to remove old data still displayed in // the window when the document whose information is displayed // changes. For example, at this time, the list of images of the Media // tab is cleared. var onResetRegistry = []; // These functions are called once when all the elements in all of the target // document (and all of its subframes, if any) have been processed var onFinished = []; // These functions are called once when the Page Info window is closed. var onUnloadRegistry = []; /* Called when PageInfo window is loaded. Arguments are: * window.arguments[0] - (optional) an object consisting of * - doc: (optional) document to use for source. if not provided, Loading @@ -338,18 +302,19 @@ async function onLoadPageInfo() { gStrings.mediaVideo = await document.l10n.formatValue("media-video"); gStrings.mediaAudio = await document.l10n.formatValue("media-audio"); var args = const args = "arguments" in window && window.arguments.length >= 1 && window.arguments[0]; // init media view var imageTree = document.getElementById("imagetree"); imageTree.view = gImageView; // Init media view document.getElementById("imagetree").view = gImageView; /* Select the requested tab, if the name is specified */ loadTab(args); Services.obs.notifyObservers(window, "page-info-dialog-loaded"); // Select the requested tab, if the name is specified await loadTab(args); // Emit init event for tests window.dispatchEvent(new Event("page-info-init")); } async function loadPageInfo(browsingContext, imageElement, browser) { Loading Loading @@ -389,25 +354,14 @@ async function loadPageInfo(browsingContext, imageElement, browser) { selectImage(); contextsToVisit.push(...currContext.children); } /* Call registered overlay init functions */ onLoadRegistry.forEach(function(func) { func(); }); onFinished.forEach(function(func) { func(); }); } /** * onNonMediaPageInfoLoad is responsible for populating the page info * UI other than the media tab. This includes general, permissions, and security. */ async function onNonMediaPageInfoLoad(browser, args, imageInfo) { let pageInfoData = args; let docInfo = pageInfoData.docInfo; let windowInfo = pageInfoData.windowInfo; async function onNonMediaPageInfoLoad(browser, pageInfoData, imageInfo) { const { docInfo, windowInfo } = pageInfoData; let uri = Services.io.newURI(docInfo.documentURIObject.spec); let principal = docInfo.principal; gDocInfo = docInfo; Loading Loading @@ -451,22 +405,10 @@ function resetPageInfo(args) { gImageView.clear(); gImageHash = {}; /* Call registered overlay reset functions */ onResetRegistry.forEach(function(func) { func(); }); /* Rebuild the data */ loadTab(args); } function onUnloadPageInfo() { /* Call registered overlay unload functions */ onUnloadRegistry.forEach(function(func) { func(); }); } function doHelpButton() { const helpTopics = { generalPanel: "pageinfo_general", Loading @@ -489,14 +431,14 @@ function showTab(id) { async function loadTab(args) { // If the "View Image Info" context menu item was used, the related image // element is provided as an argument. This can't be a background image. let imageElement = args && args.imageElement; let browsingContext = args && args.browsingContext; let browser = args && args.browser; let imageElement = args?.imageElement; let browsingContext = args?.browsingContext; let browser = args?.browser; /* Load the page info */ loadPageInfo(browsingContext, imageElement, browser); await loadPageInfo(browsingContext, imageElement, browser); var initialTab = (args && args.initialTab) || "generalTab"; var initialTab = args?.initialTab || "generalTab"; var radioGroup = document.getElementById("viewGroup"); initialTab = document.getElementById(initialTab) || Loading Loading @@ -547,8 +489,7 @@ async function makeGeneralTab(metaViewRows, docInfo) { document.l10n.setAttributes(document.getElementById("modetext"), mode); // find out the mime type var mimeType = docInfo.contentType; setItemValue("typetext", mimeType); setItemValue("typetext", docInfo.contentType); // get the document characterset var encoding = docInfo.characterSet; Loading @@ -566,8 +507,7 @@ async function makeGeneralTab(metaViewRows, docInfo) { { tags: length } ); var metaTree = document.getElementById("metatree"); metaTree.view = gMetaView; document.getElementById("metatree").view = gMetaView; // Add the metaViewRows onto the general tab's meta info tree. gMetaView.addRows(metaViewRows); Loading @@ -584,7 +524,6 @@ async function makeGeneralTab(metaViewRows, docInfo) { // get cache info var cacheKey = url.replace(/#.*$/, ""); openCacheEntry(cacheKey, function(cacheEntry) { var sizeText; if (cacheEntry) { var pageSize = cacheEntry.dataSize; var kbSize = formatNumber(Math.round((pageSize / 1024) * 100) / 100); Loading @@ -594,7 +533,7 @@ async function makeGeneralTab(metaViewRows, docInfo) { { kb: kbSize, bytes: formatNumber(pageSize) } ); } else { setItemValue("sizetext", sizeText); setItemValue("sizetext", null); } }); } Loading Loading @@ -658,11 +597,6 @@ async function addImage(imageViewRow) { } // Link Stuff function openURL(target) { var url = target.parentNode.childNodes[2].value; window.open(url, "_blank", "chrome"); } function onBeginLinkDrag(event, urlField, descField) { if (event.originalTarget.localName != "treechildren") { return; Loading Loading @@ -713,8 +647,7 @@ function getSelectedRow(tree) { } async function selectSaveFolder(aCallback) { const nsIFile = Ci.nsIFile; const nsIFilePicker = Ci.nsIFilePicker; const { nsIFile, nsIFilePicker } = Ci; let titleText = await document.l10n.formatValue("media-select-folder"); let fp = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); let fpCallback = function fpCallback_done(aResult) { Loading Loading @@ -1027,10 +960,7 @@ function makePreview(row) { } else { // Handle the case where newImage is not used for width & height if (item.HTMLVideoElement && isProtocolAllowed) { newImage = document.createElementNS( "http://www.w3.org/1999/xhtml", "video" ); newImage = document.createElement("video"); newImage.id = "thepreviewimage"; newImage.setAttribute("triggeringprincipal", triggeringPrinStr); newImage.src = url; Loading browser/base/content/pageinfo/pageInfo.xhtml +0 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ data-l10n-attrs="style" windowtype="Browser:page-info" onload="onLoadPageInfo()" onunload="onUnloadPageInfo()" align="stretch" screenX="10" screenY="10" persist="screenX screenY width height sizemode"> Loading browser/base/content/pageinfo/permissions.js +1 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ function onLoadPermission(uri, principal) { initRow(i); } Services.obs.addObserver(permissionObserver, "perm-changed"); onUnloadRegistry.push(onUnloadPermission); window.addEventListener("unload", onUnloadPermission); permTab.hidden = false; } else { permTab.hidden = true; Loading browser/base/content/test/pageinfo/browser_pageinfo_firstPartyIsolation.js +46 −58 Original line number Diff line number Diff line const Cm = Components.manager; function testFirstPartyDomain(pageInfo) { return new Promise(resolve => { async function testFirstPartyDomain(pageInfo) { const EXPECTED_DOMAIN = "example.com"; info("pageInfo load"); pageInfo.onFinished.push(async function() { info("pageInfo onfinished"); await BrowserTestUtils.waitForEvent(pageInfo, "page-info-init"); info("pageInfo initialized"); let tree = pageInfo.document.getElementById("imagetree"); Assert.ok(!!tree, "should have imagetree element"); Loading Loading @@ -37,33 +35,23 @@ function testFirstPartyDomain(pageInfo) { // it won't have origin attributes, now we've changed to loadingPrincipal // to the content in bug 1376971, it should have firstPartyDomain set. if (i == 0) { let req = preview.getRequest( Ci.nsIImageLoadingContent.CURRENT_REQUEST ); let req = preview.getRequest(Ci.nsIImageLoadingContent.CURRENT_REQUEST); Assert.equal( req.imagePrincipal.originAttributes.firstPartyDomain, EXPECTED_DOMAIN, "imagePrincipal should have firstPartyDomain set to " + EXPECTED_DOMAIN "imagePrincipal should have firstPartyDomain set to " + EXPECTED_DOMAIN ); } // Check the node has the attribute 'triggeringprincipal'. let loadingPrincipalStr = preview.getAttribute("triggeringprincipal"); let loadingPrincipal = E10SUtils.deserializePrincipal( loadingPrincipalStr ); let loadingPrincipal = E10SUtils.deserializePrincipal(loadingPrincipalStr); Assert.equal( loadingPrincipal.originAttributes.firstPartyDomain, EXPECTED_DOMAIN, "loadingPrincipal should have firstPartyDomain set to " + EXPECTED_DOMAIN "loadingPrincipal should have firstPartyDomain set to " + EXPECTED_DOMAIN ); } resolve(); }); }); } async function test() { Loading browser/base/content/test/pageinfo/browser_pageinfo_iframe_media.js +2 −4 Original line number Diff line number Diff line Loading @@ -13,10 +13,8 @@ add_task(async function test_all_images_mentioned() { gBrowser.selectedBrowser.currentURI.spec, "mediaTab" ); await BrowserTestUtils.waitForEvent(pageInfo, "load"); await new Promise(resolve => pageInfo.onFinished.push(() => executeSoon(resolve)) ); await BrowserTestUtils.waitForEvent(pageInfo, "page-info-init"); let imageTree = pageInfo.document.getElementById("imagetree"); let imageRowsNum = imageTree.view.rowCount; Loading Loading
browser/base/content/pageinfo/pageInfo.js +20 −90 Original line number Diff line number Diff line Loading @@ -281,42 +281,6 @@ function getClipboardHelper() { } const gClipboardHelper = getClipboardHelper(); // namespaces, don't need all of these yet... const XLinkNS = "http://www.w3.org/1999/xlink"; const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; const XMLNS = "http://www.w3.org/XML/1998/namespace"; const XHTMLNS = "http://www.w3.org/1999/xhtml"; const XHTML2NS = "http://www.w3.org/2002/06/xhtml2"; const XHTMLNSre = "^http://www.w3.org/1999/xhtml$"; const XHTML2NSre = "^http://www.w3.org/2002/06/xhtml2$"; const XHTMLre = RegExp(XHTMLNSre + "|" + XHTML2NSre, ""); /* Overlays register functions here. * These arrays are used to hold callbacks that Page Info will call at * various stages. Use them by simply appending a function to them. * For example, add a function to onLoadRegistry by invoking * "onLoadRegistry.push(XXXLoadFunc);" * The XXXLoadFunc should be unique to the overlay module, and will be * invoked as "XXXLoadFunc();" */ // These functions are called to build the data displayed in the Page Info window. var onLoadRegistry = []; // These functions are called to remove old data still displayed in // the window when the document whose information is displayed // changes. For example, at this time, the list of images of the Media // tab is cleared. var onResetRegistry = []; // These functions are called once when all the elements in all of the target // document (and all of its subframes, if any) have been processed var onFinished = []; // These functions are called once when the Page Info window is closed. var onUnloadRegistry = []; /* Called when PageInfo window is loaded. Arguments are: * window.arguments[0] - (optional) an object consisting of * - doc: (optional) document to use for source. if not provided, Loading @@ -338,18 +302,19 @@ async function onLoadPageInfo() { gStrings.mediaVideo = await document.l10n.formatValue("media-video"); gStrings.mediaAudio = await document.l10n.formatValue("media-audio"); var args = const args = "arguments" in window && window.arguments.length >= 1 && window.arguments[0]; // init media view var imageTree = document.getElementById("imagetree"); imageTree.view = gImageView; // Init media view document.getElementById("imagetree").view = gImageView; /* Select the requested tab, if the name is specified */ loadTab(args); Services.obs.notifyObservers(window, "page-info-dialog-loaded"); // Select the requested tab, if the name is specified await loadTab(args); // Emit init event for tests window.dispatchEvent(new Event("page-info-init")); } async function loadPageInfo(browsingContext, imageElement, browser) { Loading Loading @@ -389,25 +354,14 @@ async function loadPageInfo(browsingContext, imageElement, browser) { selectImage(); contextsToVisit.push(...currContext.children); } /* Call registered overlay init functions */ onLoadRegistry.forEach(function(func) { func(); }); onFinished.forEach(function(func) { func(); }); } /** * onNonMediaPageInfoLoad is responsible for populating the page info * UI other than the media tab. This includes general, permissions, and security. */ async function onNonMediaPageInfoLoad(browser, args, imageInfo) { let pageInfoData = args; let docInfo = pageInfoData.docInfo; let windowInfo = pageInfoData.windowInfo; async function onNonMediaPageInfoLoad(browser, pageInfoData, imageInfo) { const { docInfo, windowInfo } = pageInfoData; let uri = Services.io.newURI(docInfo.documentURIObject.spec); let principal = docInfo.principal; gDocInfo = docInfo; Loading Loading @@ -451,22 +405,10 @@ function resetPageInfo(args) { gImageView.clear(); gImageHash = {}; /* Call registered overlay reset functions */ onResetRegistry.forEach(function(func) { func(); }); /* Rebuild the data */ loadTab(args); } function onUnloadPageInfo() { /* Call registered overlay unload functions */ onUnloadRegistry.forEach(function(func) { func(); }); } function doHelpButton() { const helpTopics = { generalPanel: "pageinfo_general", Loading @@ -489,14 +431,14 @@ function showTab(id) { async function loadTab(args) { // If the "View Image Info" context menu item was used, the related image // element is provided as an argument. This can't be a background image. let imageElement = args && args.imageElement; let browsingContext = args && args.browsingContext; let browser = args && args.browser; let imageElement = args?.imageElement; let browsingContext = args?.browsingContext; let browser = args?.browser; /* Load the page info */ loadPageInfo(browsingContext, imageElement, browser); await loadPageInfo(browsingContext, imageElement, browser); var initialTab = (args && args.initialTab) || "generalTab"; var initialTab = args?.initialTab || "generalTab"; var radioGroup = document.getElementById("viewGroup"); initialTab = document.getElementById(initialTab) || Loading Loading @@ -547,8 +489,7 @@ async function makeGeneralTab(metaViewRows, docInfo) { document.l10n.setAttributes(document.getElementById("modetext"), mode); // find out the mime type var mimeType = docInfo.contentType; setItemValue("typetext", mimeType); setItemValue("typetext", docInfo.contentType); // get the document characterset var encoding = docInfo.characterSet; Loading @@ -566,8 +507,7 @@ async function makeGeneralTab(metaViewRows, docInfo) { { tags: length } ); var metaTree = document.getElementById("metatree"); metaTree.view = gMetaView; document.getElementById("metatree").view = gMetaView; // Add the metaViewRows onto the general tab's meta info tree. gMetaView.addRows(metaViewRows); Loading @@ -584,7 +524,6 @@ async function makeGeneralTab(metaViewRows, docInfo) { // get cache info var cacheKey = url.replace(/#.*$/, ""); openCacheEntry(cacheKey, function(cacheEntry) { var sizeText; if (cacheEntry) { var pageSize = cacheEntry.dataSize; var kbSize = formatNumber(Math.round((pageSize / 1024) * 100) / 100); Loading @@ -594,7 +533,7 @@ async function makeGeneralTab(metaViewRows, docInfo) { { kb: kbSize, bytes: formatNumber(pageSize) } ); } else { setItemValue("sizetext", sizeText); setItemValue("sizetext", null); } }); } Loading Loading @@ -658,11 +597,6 @@ async function addImage(imageViewRow) { } // Link Stuff function openURL(target) { var url = target.parentNode.childNodes[2].value; window.open(url, "_blank", "chrome"); } function onBeginLinkDrag(event, urlField, descField) { if (event.originalTarget.localName != "treechildren") { return; Loading Loading @@ -713,8 +647,7 @@ function getSelectedRow(tree) { } async function selectSaveFolder(aCallback) { const nsIFile = Ci.nsIFile; const nsIFilePicker = Ci.nsIFilePicker; const { nsIFile, nsIFilePicker } = Ci; let titleText = await document.l10n.formatValue("media-select-folder"); let fp = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); let fpCallback = function fpCallback_done(aResult) { Loading Loading @@ -1027,10 +960,7 @@ function makePreview(row) { } else { // Handle the case where newImage is not used for width & height if (item.HTMLVideoElement && isProtocolAllowed) { newImage = document.createElementNS( "http://www.w3.org/1999/xhtml", "video" ); newImage = document.createElement("video"); newImage.id = "thepreviewimage"; newImage.setAttribute("triggeringprincipal", triggeringPrinStr); newImage.src = url; Loading
browser/base/content/pageinfo/pageInfo.xhtml +0 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ data-l10n-attrs="style" windowtype="Browser:page-info" onload="onLoadPageInfo()" onunload="onUnloadPageInfo()" align="stretch" screenX="10" screenY="10" persist="screenX screenY width height sizemode"> Loading
browser/base/content/pageinfo/permissions.js +1 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ function onLoadPermission(uri, principal) { initRow(i); } Services.obs.addObserver(permissionObserver, "perm-changed"); onUnloadRegistry.push(onUnloadPermission); window.addEventListener("unload", onUnloadPermission); permTab.hidden = false; } else { permTab.hidden = true; Loading
browser/base/content/test/pageinfo/browser_pageinfo_firstPartyIsolation.js +46 −58 Original line number Diff line number Diff line const Cm = Components.manager; function testFirstPartyDomain(pageInfo) { return new Promise(resolve => { async function testFirstPartyDomain(pageInfo) { const EXPECTED_DOMAIN = "example.com"; info("pageInfo load"); pageInfo.onFinished.push(async function() { info("pageInfo onfinished"); await BrowserTestUtils.waitForEvent(pageInfo, "page-info-init"); info("pageInfo initialized"); let tree = pageInfo.document.getElementById("imagetree"); Assert.ok(!!tree, "should have imagetree element"); Loading Loading @@ -37,33 +35,23 @@ function testFirstPartyDomain(pageInfo) { // it won't have origin attributes, now we've changed to loadingPrincipal // to the content in bug 1376971, it should have firstPartyDomain set. if (i == 0) { let req = preview.getRequest( Ci.nsIImageLoadingContent.CURRENT_REQUEST ); let req = preview.getRequest(Ci.nsIImageLoadingContent.CURRENT_REQUEST); Assert.equal( req.imagePrincipal.originAttributes.firstPartyDomain, EXPECTED_DOMAIN, "imagePrincipal should have firstPartyDomain set to " + EXPECTED_DOMAIN "imagePrincipal should have firstPartyDomain set to " + EXPECTED_DOMAIN ); } // Check the node has the attribute 'triggeringprincipal'. let loadingPrincipalStr = preview.getAttribute("triggeringprincipal"); let loadingPrincipal = E10SUtils.deserializePrincipal( loadingPrincipalStr ); let loadingPrincipal = E10SUtils.deserializePrincipal(loadingPrincipalStr); Assert.equal( loadingPrincipal.originAttributes.firstPartyDomain, EXPECTED_DOMAIN, "loadingPrincipal should have firstPartyDomain set to " + EXPECTED_DOMAIN "loadingPrincipal should have firstPartyDomain set to " + EXPECTED_DOMAIN ); } resolve(); }); }); } async function test() { Loading
browser/base/content/test/pageinfo/browser_pageinfo_iframe_media.js +2 −4 Original line number Diff line number Diff line Loading @@ -13,10 +13,8 @@ add_task(async function test_all_images_mentioned() { gBrowser.selectedBrowser.currentURI.spec, "mediaTab" ); await BrowserTestUtils.waitForEvent(pageInfo, "load"); await new Promise(resolve => pageInfo.onFinished.push(() => executeSoon(resolve)) ); await BrowserTestUtils.waitForEvent(pageInfo, "page-info-init"); let imageTree = pageInfo.document.getElementById("imagetree"); let imageRowsNum = imageTree.view.rowCount; Loading