Commit aa292f21 authored by Wes Kocher's avatar Wes Kocher
Browse files

Merge autoland to central, a=merge

MozReview-Commit-ID: 1jc25nYhPbA
parents 39e4b25a 2d939c8b
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -39,10 +39,27 @@ var gSafeBrowsing = {

  /**
   * Used to report a phishing page or a false positive
   * @param name String One of "Phish", "Error", "Malware" or "MalwareError"
   *
   * @param name
   *        String One of "PhishMistake", "MalwareMistake", or "Phish"
   * @param info
   *        Information about the reasons for blocking the resource.
   *        In the case false positive, it may contain SafeBrowsing
   *        matching list and provider of the list
   * @return String the report phishing URL.
   */
  getReportURL(name) {
    return SafeBrowsing.getReportURL(name, gBrowser.currentURI);
  getReportURL(name, info) {
    let reportInfo = info;
    if (!reportInfo) {
      let pageUri = gBrowser.currentURI.clone();

      // Remove the query to avoid including potentially sensitive data
      if (pageUri instanceof Ci.nsIURL) {
        pageUri.query = "";
      }

      reportInfo = { uri: pageUri.asciiSpec };
    }
    return SafeBrowsing.getReportURL(name, reportInfo);
  }
}
+31 −20
Original line number Diff line number Diff line
@@ -2972,7 +2972,8 @@ var BrowserOnClick = {
      break;
      case "Browser:SiteBlockedError":
        this.onAboutBlocked(msg.data.elementId, msg.data.reason,
                            msg.data.isTopFrame, msg.data.location);
                            msg.data.isTopFrame, msg.data.location,
                            msg.data.blockedInfo);
      break;
      case "Browser:EnableOnlineMode":
        if (Services.io.offline) {
@@ -3097,7 +3098,7 @@ var BrowserOnClick = {
    }
  },

  onAboutBlocked(elementId, reason, isTopFrame, location) {
  onAboutBlocked(elementId, reason, isTopFrame, location, blockedInfo) {
    // Depending on what page we are displaying here (malware/phishing/unwanted)
    // use the right strings and links for each.
    let bucketName = "";
@@ -3140,13 +3141,13 @@ var BrowserOnClick = {
          if (sendTelemetry) {
            secHistogram.add(nsISecTel[bucketName + "IGNORE_WARNING"]);
          }
          this.ignoreWarningButton(reason);
          this.ignoreWarningButton(reason, blockedInfo);
        }
        break;
    }
  },

  ignoreWarningButton(reason) {
  ignoreWarningButton(reason, blockedInfo) {
    // Allow users to override and continue through to the site,
    // but add a notify bar as a reminder, so that they don't lose
    // track after, e.g., tab switching.
@@ -3166,23 +3167,33 @@ var BrowserOnClick = {

    let title;
    if (reason === "malware") {
      title = gNavigatorBundle.getString("safebrowsing.reportedAttackSite");
      let reportUrl = gSafeBrowsing.getReportURL("MalwareMistake", blockedInfo);

      // There's no button if we can not get report url, for example if the provider
      // of blockedInfo is not Google
      if (reportUrl) {
        buttons[1] = {
          label: gNavigatorBundle.getString("safebrowsing.notAnAttackButton.label"),
          accessKey: gNavigatorBundle.getString("safebrowsing.notAnAttackButton.accessKey"),
          callback() {
          openUILinkIn(gSafeBrowsing.getReportURL("MalwareMistake"), "tab");
            openUILinkIn(reportUrl, "tab");
          }
        };
      }
    } else if (reason === "phishing") {
      title = gNavigatorBundle.getString("safebrowsing.deceptiveSite");
      let reportUrl = gSafeBrowsing.getReportURL("PhishMistake", blockedInfo);

      // There's no button if we can not get report url, for example if the provider
      // of blockedInfo is not Google
      if (reportUrl) {
        buttons[1] = {
          label: gNavigatorBundle.getString("safebrowsing.notADeceptiveSiteButton.label"),
          accessKey: gNavigatorBundle.getString("safebrowsing.notADeceptiveSiteButton.accessKey"),
          callback() {
          openUILinkIn(gSafeBrowsing.getReportURL("PhishMistake"), "tab");
            openUILinkIn(reportUrl, "tab");
          }
        };
      }
    } else if (reason === "unwanted") {
      title = gNavigatorBundle.getString("safebrowsing.reportedUnwantedSite");
      // There is no button for reporting errors since Google doesn't currently
+26 −1
Original line number Diff line number Diff line
@@ -575,11 +575,36 @@ var ClickEventHandler = {
    } else if (/e=unwantedBlocked/.test(ownerDoc.documentURI)) {
      reason = "unwanted";
    }

    let docShell = ownerDoc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
                                       .getInterface(Ci.nsIWebNavigation)
                                      .QueryInterface(Ci.nsIDocShell);
    let blockedInfo = {};
    if (docShell.failedChannel) {
      let classifiedChannel = docShell.failedChannel.
                              QueryInterface(Ci.nsIClassifiedChannel);
      if (classifiedChannel) {
        let httpChannel = docShell.failedChannel.QueryInterface(Ci.nsIHttpChannel);

        let reportUri = httpChannel.URI.clone();

        // Remove the query to avoid leaking sensitive data
        if (reportUri instanceof Ci.nsIURL) {
          reportUri.query = "";
        }

        blockedInfo = { list: classifiedChannel.matchedList,
                        provider: classifiedChannel.matchedProvider,
                        uri: reportUri.asciiSpec };
      }
    }

    sendAsyncMessage("Browser:SiteBlockedError", {
      location: ownerDoc.location.href,
      reason,
      elementId: targetElement.getAttribute("id"),
      isTopFrame: (ownerDoc.defaultView.parent === ownerDoc.defaultView)
      isTopFrame: (ownerDoc.defaultView.parent === ownerDoc.defaultView),
      blockedInfo
    });
  },

+1 −6
Original line number Diff line number Diff line
@@ -13,12 +13,7 @@ add_task(function* checkBackFromInvalidURI() {
  gURLBar.value = "::2600";
  gURLBar.focus();

  let promiseErrorPageLoaded = new Promise(resolve => {
    tab.linkedBrowser.addEventListener("DOMContentLoaded", function onLoad() {
      tab.linkedBrowser.removeEventListener("DOMContentLoaded", onLoad, false, true);
      resolve();
    }, false, true);
  });
  let promiseErrorPageLoaded = BrowserTestUtils.waitForErrorPage(tab.linkedBrowser);
  EventUtils.synthesizeKey("VK_RETURN", {});
  yield promiseErrorPageLoaded;

+5 −1
Original line number Diff line number Diff line
@@ -108,8 +108,12 @@ var observer = {
};

function waitForMozAfterPaint(win, callback) {
  let dwu = win.QueryInterface(Ci.nsIInterfaceRequestor)
               .getInterface(Ci.nsIDOMWindowUtils);
  let lastTransactionId = dwu.lastTransactionId;

  win.addEventListener("MozAfterPaint", function onEnd(event) {
    if (event.target != win)
    if (event.target != win || event.transactionId <= lastTransactionId)
      return;
    win.removeEventListener("MozAfterPaint", onEnd);
    executeSoon(callback);
Loading