Commit c3884848 authored by Noemi Erli's avatar Noemi Erli
Browse files

Backed out changeset 2c05887675ef (bug 1816153) for causing failures in...

Backed out changeset 2c05887675ef (bug 1816153) for causing failures in browser_startup_images.js CLOSED TREE
parent 943c3668
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -175,12 +175,6 @@
    </popupnotification>

    <popupnotification id="identity-credential-notification" hidden="true">
      <popupnotificationheader id="identity-credential-header" orient="horizontal" hidden="true">
        <html:div class="identity-credential-header-container">
          <html:img class="identity-credential-header-icon" src="chrome://global/skin/icons/defaultFavicon.svg"></html:img>
          <span id="identity-credential-header-text"></span>
        </html:div>
      </popupnotificationheader>
      <popupnotificationcontent id="identity-credential-provider" orient="vertical">
        <html:div id="identity-credential-provider-selector-container">
        </html:div>
+0 −15
Original line number Diff line number Diff line
@@ -25,21 +25,6 @@
  overflow: auto;
}

#identity-credential-header-text {
  font-weight: 600;
}

.identity-credential-header-container {
  margin: 16px 16px -16px 16px;
  display: flex;
}

.identity-credential-header-icon {
  width: 16px;
  height: 16px;
  margin-inline-end: 8px;
}

.identity-credential-list-item {
  display: flex;
  gap: 10px;
+24 −74
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
  false
);

const BEST_HEADER_ICON_SIZE = 16;
const BEST_ICON_SIZE = 32;

// Used in plain mochitests to enable automation
@@ -67,30 +66,6 @@ export class IdentityCredentialPromptService {
    "nsIIdentityCredentialPromptService",
  ]);

  async loadIconFromManifest(providerManifest, bestIconSize = BEST_ICON_SIZE) {
    if (providerManifest?.branding?.icons?.length) {
      // Prefer a vector icon, then an exactly sized icon,
      // the the largest icon available.
      let iconsArray = providerManifest.branding.icons;
      let vectorIcon = iconsArray.find(icon => !icon.size);
      if (vectorIcon) {
        return fetchToDataUrl(vectorIcon.url);
      }
      let exactIcon = iconsArray.find(icon => icon.size == bestIconSize);
      if (exactIcon) {
        return fetchToDataUrl(exactIcon.url);
      }
      let biggestIcon = iconsArray.sort(
        (iconA, iconB) => iconB.size - iconA.size
      )[0];
      if (biggestIcon) {
        return fetchToDataUrl(biggestIcon.url);
      }
    }

    return null;
  }

  /**
   * Ask the user, using a PopupNotification, to select an Identity Provider from a provided list.
   * @param {BrowsingContext} browsingContext - The BrowsingContext of the document requesting an identity credential via navigator.credentials.get()
@@ -117,11 +92,29 @@ export class IdentityCredentialPromptService {
    }

    // Map each identity manifest to a promise that would resolve to its icon
    let promises = identityManifests.map(async providerManifest => {
      const iconResult = await this.loadIconFromManifest(providerManifest);
    let promises = identityManifests.map(providerManifest => {
      if (providerManifest?.branding?.icons?.length) {
        // Prefer a vector icon, then an exactly sized icon,
        // the the largest icon available.
        let iconsArray = providerManifest.branding.icons;
        let vectorIcon = iconsArray.find(icon => !icon.size);
        if (vectorIcon) {
          return fetchToDataUrl(vectorIcon.url);
        }
        let exactIcon = iconsArray.find(icon => icon.size == BEST_ICON_SIZE);
        if (exactIcon) {
          return fetchToDataUrl(exactIcon.url);
        }
        let biggestIcon = iconsArray.sort(
          (iconA, iconB) => iconB.size - iconA.size
        )[0];
        if (biggestIcon) {
          return fetchToDataUrl(biggestIcon.url);
        }
      }
      // If we didn't have a manifest with an icon, push a rejection.
      // This will be replaced with the default icon.
      return iconResult ? iconResult : Promise.reject();
      return Promise.reject();
    });

    // Sanity check that we made one promise per IDP.
@@ -246,9 +239,6 @@ export class IdentityCredentialPromptService {
      browser.ownerDocument.getElementById(
        "identity-credential-account"
      ).hidden = true;
      browser.ownerDocument.getElementById(
        "identity-credential-header"
      ).hidden = true;
      browser.ownerGlobal.PopupNotifications.show(
        browser,
        "identity-credential",
@@ -269,7 +259,7 @@ export class IdentityCredentialPromptService {
   * @param {IdentityCredentialMetadata} identityCredentialMetadata - The metadata displayed to the user
   * @returns {Promise<bool>} A boolean representing the user's acceptance of the metadata.
   */
  async showPolicyPrompt(
  showPolicyPrompt(
    browsingContext,
    identityProvider,
    identityManifest,
@@ -286,12 +276,6 @@ export class IdentityCredentialPromptService {
    ) {
      return Promise.resolve(true);
    }

    let iconResult = await this.loadIconFromManifest(
      identityManifest,
      BEST_HEADER_ICON_SIZE
    );

    return new Promise(function(resolve, reject) {
      let browser = browsingContext.top.embedderElement;
      if (!browser) {
@@ -306,7 +290,6 @@ export class IdentityCredentialPromptService {
      );
      let currentBaseDomain =
        browsingContext.currentWindowContext.documentPrincipal.baseDomain;

      // Localize the description
      // Bug 1797154 - Convert localization calls to use the async formatValues.
      let localization = new Localization(
@@ -330,18 +313,6 @@ export class IdentityCredentialPromptService {
        }
      );

      if (iconResult) {
        let headerIcon = browser.ownerDocument.getElementsByClassName(
          "identity-credential-header-icon"
        )[0];
        headerIcon.setAttribute("src", iconResult);
      }

      const headerText = browser.ownerDocument.getElementById(
        "identity-credential-header-text"
      );
      headerText.textContent = title;

      let privacyPolicyAnchor = browser.ownerDocument.getElementById(
        "identity-credential-privacy-policy"
      );
@@ -406,11 +377,10 @@ export class IdentityCredentialPromptService {
      ).hidden = true;
      ownerDocument.getElementById("identity-credential-policy").hidden = false;
      ownerDocument.getElementById("identity-credential-account").hidden = true;
      ownerDocument.getElementById("identity-credential-header").hidden = false;
      browser.ownerGlobal.PopupNotifications.show(
        browser,
        "identity-credential",
        "",
        title,
        "identity-credential-notification-icon",
        mainAction,
        secondaryActions,
@@ -538,11 +508,6 @@ export class IdentityCredentialPromptService {
      listBox.append(newItem);
    }

    let headerIconResult = await this.loadIconFromManifest(
      providerManifest,
      BEST_HEADER_ICON_SIZE
    );

    // Create a new promise to wrap the callbacks of the popup buttons
    return new Promise(function(resolve, reject) {
      // Construct the necessary arguments for notification behavior
@@ -574,18 +539,6 @@ export class IdentityCredentialPromptService {
        },
      ];

      if (headerIconResult) {
        let headerIcon = browser.ownerDocument.getElementsByClassName(
          "identity-credential-header-icon"
        )[0];
        headerIcon.setAttribute("src", headerIconResult);
      }

      const headerText = browser.ownerDocument.getElementById(
        "identity-credential-header-text"
      );
      headerText.textContent = headerMessage;

      // Show the popup
      browser.ownerDocument.getElementById(
        "identity-credential-provider"
@@ -596,13 +549,10 @@ export class IdentityCredentialPromptService {
      browser.ownerDocument.getElementById(
        "identity-credential-account"
      ).hidden = false;
      browser.ownerDocument.getElementById(
        "identity-credential-header"
      ).hidden = false;
      browser.ownerGlobal.PopupNotifications.show(
        browser,
        "identity-credential",
        "",
        headerMessage,
        "identity-credential-notification-icon",
        mainAction,
        secondaryActions,
+3 −26
Original line number Diff line number Diff line
@@ -72,7 +72,9 @@ add_task(async function test_single_acccount_dialog() {
    "Label includes the account email"
  );

  let title = document.getElementById("identity-credential-header-text");
  let title = document.querySelector(
    'description[popupid="identity-credential"]'
  );
  ok(
    title.textContent.includes("idp.example"),
    "Popup title includes the IDP Site"
@@ -390,19 +392,6 @@ add_task(async function test_multiple_acccount_show_picture() {
      accounts_endpoint: "",
      client_metadata_endpoint: "",
      id_assertion_endpoint: "",
      privacy_policy_url: "https://idp.example/privacy-policy.html",
      terms_of_service_url: "https://idp.example/terms-of-service.html",
      branding: {
        background_color: "0x6200ee",
        color: "0xffffff",
        icons: [
          {
            size: 256,
            url:
              "https://example.net/browser/toolkit/components/credentialmanagement/tests/browser/custom.svg",
          },
        ],
      },
    }
  );

@@ -428,18 +417,6 @@ add_task(async function test_multiple_acccount_show_picture() {
    "The first icon matches the custom.svg"
  );

  const headerIcon = document.getElementsByClassName(
    "identity-credential-header-icon"
  )[0];

  ok(BrowserTestUtils.is_visible(headerIcon), "Header Icon is showing");
  ok(
    headerIcon.src.startsWith(
      "data:image/svg+xml;base64,PCEtLSBUaGlzIFNvdXJjZSBDb2RlIEZvcm0gaXMgc3ViamVjdCB0byB0aGUgdGVybXMgb2YgdGhlIE1vemlsbGEgUHVibGljCiAgIC0gTGljZW5zZSwgdi4gMi4wLiBJZiBhIGNvcHkgb2YgdGhlIE1QTCB3YXMgbm90IGRpc3RyaWJ1dGVkIHdpdGggdGhpcwogICAtIGZpbGUsIFlvdSBjYW4gb2J0YWluIG9uZSBhdCBodHRwOi8vbW96aWxsYS5vcmcvTVBMLzIuMC8uIC0tPgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDE2IDE2IiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9ImNvbnRleHQtZmlsbCIgZmlsbC1vcGFjaXR5PSJjb250ZXh0LWZpbGwtb3BhY2l0eSI+CiAgPHBhdGggZD0iTS42MjUgMTNhLjYyNS42MjUgMCAwIDEgMC0xLjI1bDMuMjUgMEE0Ljg4IDQuODggMCAwIDAgOC43NSA2Ljg3NWwwLS4yNWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBsMCAuMjVBNi4xMzIgNi4xMzIgMCAwIDEgMy44NzUgMTNsLTMuMjUgMHoiLz"
    ),
    "The header icon matches the icon resource from manifest"
  );

  // Click Continue
  document
    .getElementsByClassName("popup-notification-primary-button")[0]
+3 −24
Original line number Diff line number Diff line
@@ -60,17 +60,6 @@ add_task(async function test_policy_dialog() {
      accounts_endpoint: "",
      client_metadata_endpoint: "",
      id_assertion_endpoint: "",
      branding: {
        background_color: "0x6200ee",
        color: "0xffffff",
        icons: [
          {
            size: 256,
            url:
              "https://example.net/browser/toolkit/components/credentialmanagement/tests/browser/custom.svg",
          },
        ],
      },
    },
    {
      privacy_policy_url: "https://idp.example/privacy-policy.html",
@@ -110,24 +99,14 @@ add_task(async function test_policy_dialog() {
    "Link to the ToS in the policy prompt text"
  );

  let title = document.getElementById("identity-credential-header-text");
  let title = document.querySelector(
    'description[popupid="identity-credential"]'
  );
  ok(
    title.textContent.includes("idp.example"),
    "IDP domain in the policy prompt header"
  );

  const headerIcon = document.getElementsByClassName(
    "identity-credential-header-icon"
  )[0];

  ok(BrowserTestUtils.is_visible(headerIcon), "Header Icon is showing");
  ok(
    headerIcon.src.startsWith(
      "data:image/svg+xml;base64,PCEtLSBUaGlzIFNvdXJjZSBDb2RlIEZvcm0gaXMgc3ViamVjdCB0byB0aGUgdGVybXMgb2YgdGhlIE1vemlsbGEgUHVibGljCiAgIC0gTGljZW5zZSwgdi4gMi4wLiBJZiBhIGNvcHkgb2YgdGhlIE1QTCB3YXMgbm90IGRpc3RyaWJ1dGVkIHdpdGggdGhpcwogICAtIGZpbGUsIFlvdSBjYW4gb2J0YWluIG9uZSBhdCBodHRwOi8vbW96aWxsYS5vcmcvTVBMLzIuMC8uIC0tPgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDE2IDE2IiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9ImNvbnRleHQtZmlsbCIgZmlsbC1vcGFjaXR5PSJjb250ZXh0LWZpbGwtb3BhY2l0eSI+CiAgPHBhdGggZD0iTS42MjUgMTNhLjYyNS42MjUgMCAwIDEgMC0xLjI1bDMuMjUgMEE0Ljg4IDQuODggMCAwIDAgOC43NSA2Ljg3NWwwLS4yNWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBsMCAuMjVBNi4xMzIgNi4xMzIgMCAwIDEgMy44NzUgMTNsLTMuMjUgMHoiLz"
    ),
    "The header icon matches the icon resource from manifest"
  );

  // Accept the policies
  document
    .getElementsByClassName("popup-notification-primary-button")[0]