Backout 012e92feffe6 (bug 1128027). r=bgrins a=lsblakk
authorJ. Ryan Stinnett <jryans@gmail.com>
Sun, 01 Mar 2015 19:07:21 -0600
changeset 250133 eed281422403
parent 250132 cea5c7cdfa13
child 250134 85ca6f646762
push id4511
push userjryans@gmail.com
push date2015-03-02 01:11 +0000
treeherdermozilla-beta@e49cd895e078 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins, lsblakk
bugs1128027
milestone37.0
backs out012e92feffe6
Backout 012e92feffe6 (bug 1128027). r=bgrins a=lsblakk
browser/devtools/webconsole/test/browser_webconsole_allow_mixedcontent_securityerrors.js
browser/devtools/webconsole/test/browser_webconsole_block_mixedcontent_securityerrors.js
browser/devtools/webconsole/test/browser_webconsole_bug_632275_getters_document_width.js
browser/devtools/webconsole/test/browser_webconsole_bug_737873_mixedcontent.js
browser/devtools/webconsole/test/browser_webconsole_bug_762593_insecure_passwords_web_console_warning.js
browser/devtools/webconsole/test/browser_webconsole_bug_846918_hsts_invalid-headers.js
browser/devtools/webconsole/test/head.js
--- a/browser/devtools/webconsole/test/browser_webconsole_allow_mixedcontent_securityerrors.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_allow_mixedcontent_securityerrors.js
@@ -34,17 +34,17 @@ let test = asyncTest(function* () {
         text: "Loading mixed (insecure) display content \"http://example.com/tests/image/test/mochitest/blue.png\" on a secure page",
         category: CATEGORY_SECURITY,
         severity: SEVERITY_WARNING,
         objects: true,
       },
     ],
   });
 
-  yield testClickOpenNewTab(hud, results);
+  testClickOpenNewTab(hud, results);
 });
 
 function pushPrefEnv()
 {
   let deferred = promise.defer();
   let options = {"set":
       [["security.mixed_content.block_active_content", false],
        ["security.mixed_content.block_display_content", false]
@@ -52,10 +52,23 @@ function pushPrefEnv()
   SpecialPowers.pushPrefEnv(options, deferred.resolve);
   return deferred.promise;
 }
 
 function testClickOpenNewTab(hud, results) {
   let warningNode = results[0].clickableElements[0];
   ok(warningNode, "link element");
   ok(warningNode.classList.contains("learn-more-link"), "link class name");
-  return simulateMessageLinkClick(warningNode, LEARN_MORE_URI);
+
+  // Invoke the click event and check if a new tab would open to the correct page.
+  let linkOpened = false;
+  let oldOpenUILinkIn = window.openUILinkIn;
+  window.openUILinkIn = function(aLink) {
+    if (aLink == LEARN_MORE_URI) {
+      linkOpened = true;
+    }
+  }
+
+  EventUtils.synthesizeMouse(warningNode, 2, 2, {},
+                             warningNode.ownerDocument.defaultView);
+  ok(linkOpened, "Clicking the Learn More Warning node opens the desired page");
+  window.openUILinkIn = oldOpenUILinkIn;
 }
--- a/browser/devtools/webconsole/test/browser_webconsole_block_mixedcontent_securityerrors.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_block_mixedcontent_securityerrors.js
@@ -38,21 +38,21 @@ let test = asyncTest(function* () {
         text: "Blocked loading mixed active content \"http://example.com/\"",
         category: CATEGORY_SECURITY,
         severity: SEVERITY_ERROR,
         objects: true,
       },
     ],
   });
 
-  yield testClickOpenNewTab(hud, results[0]);
+  testClickOpenNewTab(hud, results[0]);
 
   let results2 = yield mixedContentOverrideTest2(hud, browser);
 
-  yield testClickOpenNewTab(hud, results2[0]);
+  testClickOpenNewTab(hud, results2[0]);
 });
 
 function pushPrefEnv()
 {
   let deferred = promise.defer();
   let options = {"set": [["security.mixed_content.block_active_content", true],
                             ["security.mixed_content.block_display_content", true]]};
   SpecialPowers.pushPrefEnv(options, deferred.resolve);
@@ -113,10 +113,24 @@ function afterNotificationShown(hud, not
     ],
   }).then(msgs => deferred.resolve(msgs), Cu.reportError);
 }
 
 function testClickOpenNewTab(hud, match) {
   let warningNode = match.clickableElements[0];
   ok(warningNode, "link element");
   ok(warningNode.classList.contains("learn-more-link"), "link class name");
-  return simulateMessageLinkClick(warningNode, LEARN_MORE_URI);
+
+  // Invoke the click event and check if a new tab would
+  // open to the correct page.
+  let linkOpened = false;
+  let oldOpenUILinkIn = window.openUILinkIn;
+  window.openUILinkIn = function(aLink) {
+    if (aLink == LEARN_MORE_URI) {
+      linkOpened = true;
+    }
+  }
+
+  EventUtils.synthesizeMouse(warningNode, 2, 2, {},
+                             warningNode.ownerDocument.defaultView);
+  ok(linkOpened, "Clicking the Learn More Warning node opens the desired page");
+  window.openUILinkIn = oldOpenUILinkIn;
 }
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_632275_getters_document_width.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_632275_getters_document_width.js
@@ -1,11 +1,18 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+///////////////////
+//
+// Whitelisting this test.
+// As part of bug 1077403, the leaking uncaught rejection should be fixed. 
+//
+thisTestLeaksUncaughtRejectionsAndShouldBeFixed("Error: Connection closed");
+
 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-bug-632275-getters.html";
 
 let getterValue = null;
 
 function test() {
   loadTab(TEST_URI).then(() => {
     openConsole().then(consoleOpened);
   });
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_737873_mixedcontent.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_737873_mixedcontent.js
@@ -7,54 +7,65 @@
  *  Tanvi Vyas <tanvi@mozilla.com>
  *
  * ***** END LICENSE BLOCK ***** */
 
 // Tests that the Web Console Mixed Content messages are displayed
 
 const TEST_URI = "data:text/html;charset=utf8,Web Console mixed content test";
 const TEST_HTTPS_URI = "https://example.com/browser/browser/devtools/webconsole/test/test-bug-737873-mixedcontent.html";
-const LEARN_MORE_URI = "https://developer.mozilla.org/docs/Security/MixedContent";
 
 let test = asyncTest(function* () {
   Services.prefs.setBoolPref("security.mixed_content.block_display_content", false);
   Services.prefs.setBoolPref("security.mixed_content.block_active_content", false);
 
   yield loadTab(TEST_URI);
 
   let hud = yield openConsole();
 
   yield testMixedContent(hud);
 
   Services.prefs.clearUserPref("security.mixed_content.block_display_content");
   Services.prefs.clearUserPref("security.mixed_content.block_active_content");
 });
 
-let testMixedContent = Task.async(function*(hud) {
+function testMixedContent(hud) {
   content.location = TEST_HTTPS_URI;
 
-  let results = yield waitForMessages({
+  return waitForMessages({
     webconsole: hud,
     messages: [{
       text: "example.com",
       category: CATEGORY_NETWORK,
       severity: SEVERITY_WARNING,
     }],
-  });
+  }).then((results) => {
+    let msg = [...results[0].matched][0];
+    ok(msg, "page load logged");
+    ok(msg.classList.contains("mixed-content"), ".mixed-content element");
 
-  let msg = [...results[0].matched][0];
-  ok(msg, "page load logged");
-  ok(msg.classList.contains("mixed-content"), ".mixed-content element");
-
-  let link = msg.querySelector(".learn-more-link");
-  ok(link, "mixed content link element");
-  is(link.textContent, "[Mixed Content]", "link text is accurate");
+    let link = msg.querySelector(".learn-more-link");
+    ok(link, "mixed content link element");
+    is(link.textContent, "[Mixed Content]", "link text is accurate");
 
-  yield simulateMessageLinkClick(link, LEARN_MORE_URI);
+    let oldOpenLink = hud.openLink;
+    let linkOpened = false;
+    hud.openLink = (url) => {
+      is(url, "https://developer.mozilla.org/docs/Security/MixedContent",
+         "url opened");
+      linkOpened = true;
+    };
 
-  ok(!msg.classList.contains("filtered-by-type"), "message is not filtered");
+    EventUtils.synthesizeMouse(link, 2, 2, {}, link.ownerDocument.defaultView);
+
+    ok(linkOpened, "clicking the Mixed Content link opened a page");
 
-  hud.setFilterState("netwarn", false);
+    hud.openLink = oldOpenLink;
+
+    ok(!msg.classList.contains("filtered-by-type"), "message is not filtered");
+
+    hud.setFilterState("netwarn", false);
 
-  ok(msg.classList.contains("filtered-by-type"), "message is filtered");
+    ok(msg.classList.contains("filtered-by-type"), "message is filtered");
 
-  hud.setFilterState("netwarn", true);
-});
+    hud.setFilterState("netwarn", true);
+  });
+}
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_762593_insecure_passwords_web_console_warning.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_762593_insecure_passwords_web_console_warning.js
@@ -35,17 +35,31 @@ let test = asyncTest(function* () {
         name: "Insecure form action error displayed successfully",
         text: INSECURE_FORM_ACTION_MSG,
         category: CATEGORY_SECURITY,
         severity: SEVERITY_WARNING
       },
     ],
   });
 
-  yield testClickOpenNewTab(hud, result);
+  testClickOpenNewTab(hud, result);
 });
 
 function testClickOpenNewTab(hud, [result]) {
   let msg = [...result.matched][0];
   let warningNode = msg.querySelector(".learn-more-link");
   ok(warningNode, "learn more link");
-  return simulateMessageLinkClick(warningNode, INSECURE_PASSWORDS_URI);
+
+  // Invoke the click event and check if a new tab would open to the correct
+  // page
+  let linkOpened = false;
+  let oldOpenUILinkIn = window.openUILinkIn;
+  window.openUILinkIn = function(aLink) {
+    if (aLink == INSECURE_PASSWORDS_URI) {
+      linkOpened = true;
+    }
+  }
+
+  EventUtils.synthesizeMouse(warningNode, 2, 2, {},
+                             warningNode.ownerDocument.defaultView);
+  ok(linkOpened, "Clicking the Insecure Passwords Warning node opens the desired page");
+  window.openUILinkIn = oldOpenUILinkIn;
 }
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_846918_hsts_invalid-headers.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_846918_hsts_invalid-headers.js
@@ -1,35 +1,50 @@
  /* Any copyright is dedicated to the Public Domain.
   * http://creativecommons.org/publicdomain/zero/1.0/ */
 /* Tests that errors about invalid HSTS security headers are logged
  *  to the web console */
 const TEST_URI = "https://example.com/browser/browser/devtools/webconsole/test/test-bug-846918-hsts-invalid-headers.html";
 const HSTS_INVALID_HEADER_MSG = "The site specified an invalid Strict-Transport-Security header.";
 const LEARN_MORE_URI = "https://developer.mozilla.org/docs/Security/HTTP_Strict_Transport_Security";
 
-let test = asyncTest(function* () {
-  yield loadTab(TEST_URI);
-
-  let hud = yield openConsole();
-
-  let results = yield waitForMessages({
-    webconsole: hud,
-    messages: [
-      {
-        name: "Invalid HSTS header error displayed successfully",
-        text: HSTS_INVALID_HEADER_MSG,
-        category: CATEGORY_SECURITY,
-        severity: SEVERITY_WARNING,
-        objects: true,
-      },
-    ],
+function test()
+{
+  loadTab(TEST_URI).then(() => {
+    openConsole().then((hud) => {
+      waitForMessages({
+        webconsole: hud,
+        messages: [
+          {
+            name: "Invalid HSTS header error displayed successfully",
+            text: HSTS_INVALID_HEADER_MSG,
+            category: CATEGORY_SECURITY,
+            severity: SEVERITY_WARNING,
+            objects: true,
+          },
+        ],
+      }).then((results) => testClickOpenNewTab(hud, results));
+    })
   });
-
-  yield testClickOpenNewTab(hud, results);
-});
+}
 
 function testClickOpenNewTab(hud, results) {
   let warningNode = results[0].clickableElements[0];
   ok(warningNode, "link element");
   ok(warningNode.classList.contains("learn-more-link"), "link class name");
-  return simulateMessageLinkClick(warningNode, LEARN_MORE_URI);
+
+  // Invoke the click event and check if a new tab would
+  // open to the correct page.
+  let linkOpened = false;
+  let oldOpenUILinkIn = window.openUILinkIn;
+  window.openUILinkIn = function(aLink) {
+    if (aLink == LEARN_MORE_URI) {
+      linkOpened = true;
+    }
+  }
+
+  EventUtils.synthesizeMouse(warningNode, 2, 2, {},
+                             warningNode.ownerDocument.defaultView);
+  ok(linkOpened, "Clicking the Learn More Warning node opens the desired page");
+  window.openUILinkIn = oldOpenUILinkIn;
+
+  finishTest();
 }
--- a/browser/devtools/webconsole/test/head.js
+++ b/browser/devtools/webconsole/test/head.js
@@ -1625,37 +1625,8 @@ function once(target, eventName, useCapt
 
   return deferred.promise;
 }
 
 function getSourceActor(aSources, aURL) {
   let item = aSources.getItemForAttachment(a => a.source.url === aURL);
   return item && item.value;
 }
-
-/**
- * Verify that clicking on a link from a popup notification message tries to
- * open the expected URL.
- */
-function simulateMessageLinkClick(element, expectedLink) {
-  let deferred = promise.defer();
-
-  // Invoke the click event and check if a new tab would
-  // open to the correct page.
-  let oldOpenUILinkIn = window.openUILinkIn;
-  window.openUILinkIn = function(link) {
-    if (link == expectedLink) {
-      ok(true, "Clicking the message link opens the desired page");
-      window.openUILinkIn = oldOpenUILinkIn;
-      deferred.resolve();
-    }
-  };
-
-  let event = new MouseEvent("click", {
-    detail: 1,
-    button: 0,
-    bubbles: true,
-    cancelable: true
-  });
-  element.dispatchEvent(event);
-
-  return deferred.promise;
-}