Bug 1382377 - Test console against devtools.enabled pref. r=baku
☠☠ backed out by 9182a041d889 ☠ ☠
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 28 Aug 2017 19:22:58 +0200
changeset 377815 c23f8bd951728a8a459ad14a688e0ca080379cbf
parent 377814 e9156a9ede8e56245e18baa45e0f0a41e28a5792
child 377816 be5d0598f77d0e1cf2ee1a6955a7f8958f4914a3
push id94338
push userkwierso@gmail.com
push dateThu, 31 Aug 2017 02:58:58 +0000
treeherdermozilla-inbound@9ca18987dabb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1382377
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1382377 - Test console against devtools.enabled pref. r=baku MozReview-Commit-ID: GEayP1MP8PV
dom/console/tests/mochitest.ini
dom/console/tests/test_devtools_pref.html
--- a/dom/console/tests/mochitest.ini
+++ b/dom/console/tests/mochitest.ini
@@ -4,8 +4,9 @@ support-files =
 
 [test_bug659625.html]
 [test_bug978522.html]
 [test_bug979109.html]
 [test_bug989665.html]
 [test_consoleEmptyStack.html]
 [test_console_binding.html]
 [test_console_proto.html]
+[test_devtools_pref.html]
new file mode 100644
--- /dev/null
+++ b/dom/console/tests/test_devtools_pref.html
@@ -0,0 +1,65 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>Test Console with devtools preference</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+  <script type="application/javascript">
+
+function consoleListener(expected) {
+  var messages = [];
+  return new Promise(done => {
+    let observer = {
+      observe: function listener(aSubject, aTopic, aData) {
+        var obj = aSubject.wrappedJSObject;
+        messages.push(parseInt(obj.arguments[0]));
+        if (messages.length == expected) {
+          SpecialPowers.removeObserver(observer, "console-api-log-event");
+          SpecialPowers.removeObserver(observer, "console-api-profiler");
+          done(messages);
+          return;
+        }
+      }
+    };
+    SpecialPowers.addObserver(observer, "console-api-log-event");
+    SpecialPowers.addObserver(observer, "console-api-profiler");
+  });
+}
+
+SimpleTest.waitForExplicitFinish();
+(async function () {
+  var onMessages = consoleListener(4);
+
+  await SpecialPowers.pushPrefEnv({set: [["devtools.enabled", false]]});
+  console.log(1);
+  console.profile(2);
+
+  await SpecialPowers.pushPrefEnv({set: [["devtools.enabled", true]]});
+  console.log(3);
+  console.profile(4);
+
+  await SpecialPowers.pushPrefEnv({set: [["devtools.enabled", false]]});
+  console.log(5);
+  console.profile(6);
+
+  await SpecialPowers.pushPrefEnv({set: [["devtools.enabled", true]]});
+  console.log(7);
+  console.profile(8);
+
+  var messages = await onMessages;
+
+  is(messages[0], 3, "Got only console message while pref was true");
+  is(messages[1], 4, "Got only profile message while pref was true");
+  is(messages[2], 7, "Got only console message while pref was true");
+  is(messages[3], 8, "Got only profile message while pref was true");
+
+  SimpleTest.finish();
+})();
+
+
+  </script>
+</body>
+</html>