Commit 74f4fb42 authored by Bogdan Tara's avatar Bogdan Tara
Browse files

Backed out 2 changesets (bug 1632097) for browser_entry_point_telemetry.js failures CLOSED TREE

Backed out changeset a935561f64d9 (bug 1632097)
Backed out changeset 264bfa5a76dd (bug 1632097)
parent 75aa0c6d
Loading
Loading
Loading
Loading
+90 −20
Original line number Diff line number Diff line
@@ -281,6 +281,42 @@ 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,
@@ -302,19 +338,18 @@ async function onLoadPageInfo() {
  gStrings.mediaVideo = await document.l10n.formatValue("media-video");
  gStrings.mediaAudio = await document.l10n.formatValue("media-audio");

  const args =
  var args =
    "arguments" in window &&
    window.arguments.length >= 1 &&
    window.arguments[0];

  // Init media view
  document.getElementById("imagetree").view = gImageView;

  // Select the requested tab, if the name is specified
  await loadTab(args);
  // init media view
  var imageTree = document.getElementById("imagetree");
  imageTree.view = gImageView;

  // Emit init event for tests
  window.dispatchEvent(new Event("page-info-init"));
  /* Select the requested tab, if the name is specified */
  loadTab(args);
  Services.obs.notifyObservers(window, "page-info-dialog-loaded");
}

async function loadPageInfo(browsingContext, imageElement, browser) {
@@ -354,14 +389,25 @@ 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, pageInfoData, imageInfo) {
  const { docInfo, windowInfo } = pageInfoData;
async function onNonMediaPageInfoLoad(browser, args, imageInfo) {
  let pageInfoData = args;
  let docInfo = pageInfoData.docInfo;
  let windowInfo = pageInfoData.windowInfo;
  let uri = Services.io.newURI(docInfo.documentURIObject.spec);
  let principal = docInfo.principal;
  gDocInfo = docInfo;
@@ -405,10 +451,22 @@ 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",
@@ -431,14 +489,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?.imageElement;
  let browsingContext = args?.browsingContext;
  let browser = args?.browser;
  let imageElement = args && args.imageElement;
  let browsingContext = args && args.browsingContext;
  let browser = args && args.browser;

  /* Load the page info */
  await loadPageInfo(browsingContext, imageElement, browser);
  loadPageInfo(browsingContext, imageElement, browser);

  var initialTab = args?.initialTab || "generalTab";
  var initialTab = (args && args.initialTab) || "generalTab";
  var radioGroup = document.getElementById("viewGroup");
  initialTab =
    document.getElementById(initialTab) ||
@@ -489,7 +547,8 @@ async function makeGeneralTab(metaViewRows, docInfo) {
  document.l10n.setAttributes(document.getElementById("modetext"), mode);

  // find out the mime type
  setItemValue("typetext", docInfo.contentType);
  var mimeType = docInfo.contentType;
  setItemValue("typetext", mimeType);

  // get the document characterset
  var encoding = docInfo.characterSet;
@@ -507,7 +566,8 @@ async function makeGeneralTab(metaViewRows, docInfo) {
      { tags: length }
    );

    document.getElementById("metatree").view = gMetaView;
    var metaTree = document.getElementById("metatree");
    metaTree.view = gMetaView;

    // Add the metaViewRows onto the general tab's meta info tree.
    gMetaView.addRows(metaViewRows);
@@ -524,6 +584,7 @@ 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);
@@ -533,7 +594,7 @@ async function makeGeneralTab(metaViewRows, docInfo) {
        { kb: kbSize, bytes: formatNumber(pageSize) }
      );
    } else {
      setItemValue("sizetext", null);
      setItemValue("sizetext", sizeText);
    }
  });
}
@@ -597,6 +658,11 @@ 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;
@@ -647,7 +713,8 @@ function getSelectedRow(tree) {
}

async function selectSaveFolder(aCallback) {
  const { nsIFile, nsIFilePicker } = Ci;
  const nsIFile = Ci.nsIFile;
  const nsIFilePicker = Ci.nsIFilePicker;
  let titleText = await document.l10n.formatValue("media-select-folder");
  let fp = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
  let fpCallback = function fpCallback_done(aResult) {
@@ -960,7 +1027,10 @@ function makePreview(row) {
    } else {
      // Handle the case where newImage is not used for width & height
      if (item.HTMLVideoElement && isProtocolAllowed) {
        newImage = document.createElement("video");
        newImage = document.createElementNS(
          "http://www.w3.org/1999/xhtml",
          "video"
        );
        newImage.id = "thepreviewimage";
        newImage.setAttribute("triggeringprincipal", triggeringPrinStr);
        newImage.src = url;
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
  data-l10n-attrs="style"
  windowtype="Browser:page-info"
  onload="onLoadPageInfo()"
  onunload="onUnloadPageInfo()"
  align="stretch"
  screenX="10" screenY="10"
  persist="screenX screenY width height sizemode">
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ function onLoadPermission(uri, principal) {
      initRow(i);
    }
    Services.obs.addObserver(permissionObserver, "perm-changed");
    window.addEventListener("unload", onUnloadPermission);
    onUnloadRegistry.push(onUnloadPermission);
    permTab.hidden = false;
  } else {
    permTab.hidden = true;
+58 −46
Original line number Diff line number Diff line
const Cm = Components.manager;

async function testFirstPartyDomain(pageInfo) {
function testFirstPartyDomain(pageInfo) {
  return new Promise(resolve => {
    const EXPECTED_DOMAIN = "example.com";
  await BrowserTestUtils.waitForEvent(pageInfo, "page-info-init");
  info("pageInfo initialized");
    info("pageInfo load");
    pageInfo.onFinished.push(async function() {
      info("pageInfo onfinished");
      let tree = pageInfo.document.getElementById("imagetree");
      Assert.ok(!!tree, "should have imagetree element");

@@ -35,23 +37,33 @@ async 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() {
+4 −2
Original line number Diff line number Diff line
@@ -13,8 +13,10 @@ add_task(async function test_all_images_mentioned() {
        gBrowser.selectedBrowser.currentURI.spec,
        "mediaTab"
      );
      await BrowserTestUtils.waitForEvent(pageInfo, "page-info-init");

      await BrowserTestUtils.waitForEvent(pageInfo, "load");
      await new Promise(resolve =>
        pageInfo.onFinished.push(() => executeSoon(resolve))
      );
      let imageTree = pageInfo.document.getElementById("imagetree");
      let imageRowsNum = imageTree.view.rowCount;

Loading