Bug 1437855 - Enable browser_console_webconsole_iframe_messages.js in new frontend r?jdescottes draft
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Wed, 14 Feb 2018 13:39:07 +0000
changeset 758541 d451808165dff5aad167d4d95c18a17b5e9c97a9
parent 758497 5e9bd04333f20e00911b8c1dfbf2b2e070c61e2d
child 758548 d660b8bddebb675e4fb8e669f9829bb14584fe3f
push id100094
push userbmo:mratcliffe@mozilla.com
push dateThu, 22 Feb 2018 17:06:16 +0000
reviewersjdescottes
bugs1437855
milestone60.0a1
Bug 1437855 - Enable browser_console_webconsole_iframe_messages.js in new frontend r?jdescottes MozReview-Commit-ID: nMmapFxtnH
devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
devtools/client/webconsole/new-console-output/test/mochitest/browser_console_webconsole_iframe_messages.js
devtools/client/webconsole/new-console-output/test/mochitest/test-console-iframes.html
devtools/client/webconsole/new-console-output/test/mochitest/test-consoleiframes.html
devtools/client/webconsole/new-console-output/test/mochitest/test-iframe1.html
devtools/client/webconsole/new-console-output/test/mochitest/test-iframe2.html
devtools/client/webconsole/new-console-output/test/mochitest/test-iframe3.html
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
@@ -55,30 +55,30 @@ support-files =
   test-console-api-stackframe.html
   test-console-clear.html
   test-console-column.html
   test-console-count-external-file.js
   test-console-count.html
   test-console-extras.html
   test-console-filters.html
   test-console-group.html
+  test-console-iframes.html
   test-console-output-02.html
   test-console-output-03.html
   test-console-output-04.html
   test-console-output-dom-elements.html
   test-console-output-events.html
   test-console-replaced-api.html
   test-console-server-logging-array.sjs
   test-console-server-logging-backtrace.sjs
   test-console-server-logging.sjs
   test-console-table.html
   test-console-trace-async.html
   test-console-workers.html
   test-console.html
-  test-consoleiframes.html
   test-cu-reporterror.js
   test-data.json
   test-data.json^headers^
   test-duplicate-error.html
   test-encoding-ISO-8859-1.html
   test-error.html
   test-eval-in-stackframe.html
   test-exception-stackframe.html
@@ -184,17 +184,16 @@ skip-if = true # Bug 1437849
 [browser_console_nsiconsolemessage.js]
 skip-if = true # Bug 1437850
 [browser_console_open_or_focus.js]
 skip-if = true # Bug 1437851
 [browser_console_restore.js]
 [browser_console_webconsole_ctrlw_close_tab.js]
 skip-if = true # Bug 1437854
 [browser_console_webconsole_iframe_messages.js]
-skip-if = true # Bug 1437855
 [browser_console_webconsole_private_browsing.js]
 skip-if = true #	Bug 1403188
 # old console skip-if = e10s # Bug 1042253 - webconsole e10s tests
 [browser_jsterm_accessibility.js]
 [browser_jsterm_add_edited_input_to_history.js]
 [browser_jsterm_autocomplete_array_no_index.js]
 [browser_jsterm_autocomplete_cached_results.js]
 [browser_jsterm_autocomplete_crossdomain_iframe.js]
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_console_webconsole_iframe_messages.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_console_webconsole_iframe_messages.js
@@ -1,114 +1,66 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
+/* import-globals-from head.js */
+
 // Check that cached messages from nested iframes are displayed in the
 // Web/Browser Console.
 
 "use strict";
 
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
-                 "test/test-consoleiframes.html";
+                 "new-console-output/test/mochitest/test-console-iframes.html";
 
 const expectedMessages = [
-  {
-    text: "main file",
-    category: CATEGORY_WEBDEV,
-    severity: SEVERITY_LOG,
-  },
-  {
-    text: "blah",
-    category: CATEGORY_JS,
-    severity: SEVERITY_ERROR
-  },
-  {
-    text: "iframe 2",
-    category: CATEGORY_WEBDEV,
-    severity: SEVERITY_LOG
-  },
-  {
-    text: "iframe 3",
-    category: CATEGORY_WEBDEV,
-    severity: SEVERITY_LOG
-  }
+  "main file",
+  "blah",
+  "iframe 2",
+  "iframe 3"
 ];
 
-// "iframe 1" console messages can be coalesced into one if they follow each
-// other in the sequence of messages (depending on timing). If they do not, then
-// they will be displayed in the console output independently, as separate
-// messages. This is why we need to match any of the following two rules.
-const expectedMessagesAny = [
-  {
-    name: "iframe 1 (count: 2)",
-    text: "iframe 1",
-    category: CATEGORY_WEBDEV,
-    severity: SEVERITY_LOG,
-    count: 2
-  },
-  {
-    name: "iframe 1 (repeats: 2)",
-    text: "iframe 1",
-    category: CATEGORY_WEBDEV,
-    severity: SEVERITY_LOG,
-    repeats: 2
-  },
-];
+const expectedDupedMessage = "iframe 1";
 
-add_task(function* () {
+add_task(async function () {
   // On e10s, the exception is triggered in child process
   // and is ignored by test harness
   if (!Services.appinfo.browserTabsRemoteAutostart) {
     expectUncaughtException();
   }
 
-  yield loadTab(TEST_URI);
-  let hud = yield openConsole();
-  ok(hud, "web console opened");
+  let hud = await openNewTabAndConsole(TEST_URI);
 
-  yield testWebConsole(hud);
-  yield closeConsole();
+  await testMessages(hud);
+  await closeConsole();
   info("web console closed");
 
-  hud = yield HUDService.toggleBrowserConsole();
-  yield testBrowserConsole(hud);
-  yield closeConsole();
+  hud = await HUDService.toggleBrowserConsole();
+  await testBrowserConsole(hud);
+  await closeConsole();
 });
 
-function* testWebConsole(hud) {
-  yield waitForMessages({
-    webconsole: hud,
-    messages: expectedMessages,
-  });
+async function testMessages(hud) {
+  for (let message of expectedMessages) {
+    info(`checking that the message "${message}" exists`);
+    await waitFor(() => findMessage(hud, message));
+  }
 
   info("first messages matched");
 
-  yield waitForMessages({
-    webconsole: hud,
-    messages: expectedMessagesAny,
-    matchCondition: "any",
-  });
+  let messages = await findMessages(hud, expectedDupedMessage);
+  is(messages.length, 2, `${expectedDupedMessage} is present twice`);
 }
 
-function* testBrowserConsole(hud) {
+async function testBrowserConsole(hud) {
   ok(hud, "browser console opened");
 
   // TODO: The browser console doesn't show page's console.log statements
   // in e10s windows. See Bug 1241289.
   if (Services.appinfo.browserTabsRemoteAutostart) {
     todo(false, "Bug 1241289");
     return;
   }
 
-  yield waitForMessages({
-    webconsole: hud,
-    messages: expectedMessages,
-  });
-
-  info("first messages matched");
-  yield waitForMessages({
-    webconsole: hud,
-    messages: expectedMessagesAny,
-    matchCondition: "any",
-  });
+  await testMessages(hud);
 }
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-consoleiframes.html
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-console-iframes.html
--- a/devtools/client/webconsole/new-console-output/test/mochitest/test-consoleiframes.html
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/test-console-iframes.html
@@ -1,13 +1,15 @@
-<html>
-<head>
-  <script>
-  console.log("main file");
-  </script>
-</head>
-<body>
-<h1>iframe console test</h1>
-<iframe src="test-iframe1.html"></iframe>
-<iframe src="test-iframe2.html"></iframe>
-<iframe src="test-iframe3.html"></iframe>
-</body>
-</html>
\ No newline at end of file
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8">
+    <script>
+    console.log("main file");
+    </script>
+  </head>
+  <body>
+    <h1>iframe console test</h1>
+    <iframe src="test-iframe1.html"></iframe>
+    <iframe src="test-iframe2.html"></iframe>
+    <iframe src="test-iframe3.html"></iframe>
+  </body>
+</html>
--- a/devtools/client/webconsole/new-console-output/test/mochitest/test-iframe1.html
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/test-iframe1.html
@@ -1,10 +1,12 @@
-<html>
-<head>
-  <script>
-  console.log("iframe 1");
-  </script>
-</head>
-<body>
-<h1>iframe 1</h1>
-</body>
-</html>
\ No newline at end of file
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8">
+    <script>
+    console.log("iframe 1");
+    </script>
+  </head>
+  <body>
+    <h1>iframe 1</h1>
+  </body>
+</html>
--- a/devtools/client/webconsole/new-console-output/test/mochitest/test-iframe2.html
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/test-iframe2.html
@@ -1,11 +1,13 @@
-<html>
-<head>
-  <script>
-  console.log("iframe 2");
-  blah;
-  </script>
-</head>
-<body>
-<h1>iframe 2</h1>
-</body>
-</html>
\ No newline at end of file
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8">
+    <script>
+      console.log("iframe 2");
+      blah;
+    </script>
+  </head>
+  <body>
+    <h1>iframe 2</h1>
+  </body>
+</html>
--- a/devtools/client/webconsole/new-console-output/test/mochitest/test-iframe3.html
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/test-iframe3.html
@@ -1,11 +1,13 @@
-<html>
-<head>
-  <script>
-  console.log("iframe 3");
-  </script>
-</head>
-<body>
-<h1>iframe 3</h1>
-<iframe src="test-iframe1.html"></iframe>
-</body>
-</html>
\ No newline at end of file
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8">
+    <script>
+      console.log("iframe 3");
+    </script>
+  </head>
+  <body>
+    <h1>iframe 3</h1>
+    <iframe src="test-iframe1.html"></iframe>
+  </body>
+</html>