summaryrefslogtreecommitdiff
path: root/dom/console/tests
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/console/tests
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloaduxp-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/console/tests')
-rw-r--r--dom/console/tests/chrome.ini6
-rw-r--r--dom/console/tests/file_empty.html1
-rw-r--r--dom/console/tests/mochitest.ini11
-rw-r--r--dom/console/tests/test_bug659625.html92
-rw-r--r--dom/console/tests/test_bug978522.html32
-rw-r--r--dom/console/tests/test_bug979109.html32
-rw-r--r--dom/console/tests/test_bug989665.html21
-rw-r--r--dom/console/tests/test_console.xul35
-rw-r--r--dom/console/tests/test_consoleEmptyStack.html27
-rw-r--r--dom/console/tests/test_console_binding.html42
-rw-r--r--dom/console/tests/test_console_proto.html17
11 files changed, 316 insertions, 0 deletions
diff --git a/dom/console/tests/chrome.ini b/dom/console/tests/chrome.ini
new file mode 100644
index 0000000000..19582aee94
--- /dev/null
+++ b/dom/console/tests/chrome.ini
@@ -0,0 +1,6 @@
+[DEFAULT]
+skip-if = os == 'android'
+support-files =
+ file_empty.html
+
+[test_console.xul]
diff --git a/dom/console/tests/file_empty.html b/dom/console/tests/file_empty.html
new file mode 100644
index 0000000000..495c23ec8a
--- /dev/null
+++ b/dom/console/tests/file_empty.html
@@ -0,0 +1 @@
+<!DOCTYPE html><html><body></body></html>
diff --git a/dom/console/tests/mochitest.ini b/dom/console/tests/mochitest.ini
new file mode 100644
index 0000000000..2381cb1f1d
--- /dev/null
+++ b/dom/console/tests/mochitest.ini
@@ -0,0 +1,11 @@
+[DEFAULT]
+support-files =
+ file_empty.html
+
+[test_bug659625.html]
+[test_bug978522.html]
+[test_bug979109.html]
+[test_bug989665.html]
+[test_consoleEmptyStack.html]
+[test_console_binding.html]
+[test_console_proto.html]
diff --git a/dom/console/tests/test_bug659625.html b/dom/console/tests/test_bug659625.html
new file mode 100644
index 0000000000..7adf872642
--- /dev/null
+++ b/dom/console/tests/test_bug659625.html
@@ -0,0 +1,92 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=659625
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 659625</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=659625">Mozilla Bug 659625</a>
+<script type="application/javascript">
+ const { Cc, Ci } = SpecialPowers;
+ let consoleStorage = Cc["@mozilla.org/consoleAPI-storage;1"];
+ let storage = consoleStorage.getService(Ci.nsIConsoleAPIStorage);
+
+ let clearAndCheckStorage = () => {
+ console.clear();
+ ok(storage.getEvents().length === 1,
+ "Only one event remains in consoleAPIStorage");
+ ok(storage.getEvents()[0].level === "clear",
+ "Remaining event has level 'clear'");
+ }
+
+ storage.clearEvents();
+ ok(storage.getEvents().length === 0,
+ "Console is empty when test is starting");
+ clearAndCheckStorage();
+
+ console.log("log");
+ console.debug("debug");
+ console.warn("warn");
+ console.error("error");
+ console.exception("exception");
+ ok(storage.getEvents().length === 6,
+ "5 new console events have been registered for logging variants");
+ clearAndCheckStorage();
+
+ console.trace();
+ ok(storage.getEvents().length === 2,
+ "1 new console event registered for trace");
+ clearAndCheckStorage();
+
+ console.dir({});
+ ok(storage.getEvents().length === 2,
+ "1 new console event registered for dir");
+ clearAndCheckStorage();
+
+ console.count("count-label");
+ console.count("count-label");
+ ok(storage.getEvents().length === 3,
+ "2 new console events registered for 2 count calls");
+ clearAndCheckStorage();
+
+ console.group("group-label")
+ console.log("group-log");
+ ok(storage.getEvents().length === 3,
+ "2 new console events registered for group + log");
+ clearAndCheckStorage();
+
+ console.groupCollapsed("group-collapsed")
+ console.log("group-collapsed-log");
+ ok(storage.getEvents().length === 3,
+ "2 new console events registered for groupCollapsed + log");
+ clearAndCheckStorage();
+
+ console.group("closed-group-label")
+ console.log("group-log");
+ console.groupEnd()
+ ok(storage.getEvents().length === 4,
+ "3 new console events registered for group/groupEnd");
+ clearAndCheckStorage();
+
+ console.time("time-label");
+ console.timeEnd();
+ ok(storage.getEvents().length === 3,
+ "2 new console events registered for time/timeEnd");
+ clearAndCheckStorage();
+
+ console.timeStamp("timestamp-label");
+ ok(storage.getEvents().length === 2,
+ "1 new console event registered for timeStamp");
+ clearAndCheckStorage();
+
+ // Check that console.clear() clears previous clear messages
+ clearAndCheckStorage();
+
+</script>
+</body>
+</html>
diff --git a/dom/console/tests/test_bug978522.html b/dom/console/tests/test_bug978522.html
new file mode 100644
index 0000000000..33d1d56a8f
--- /dev/null
+++ b/dom/console/tests/test_bug978522.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=978522
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 978522 - basic support</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=978522">Mozilla Bug 978522</a>
+<script type="application/javascript">
+
+ console.log('%s', {
+ toString: function() {
+ console.log('%s', {
+ toString: function() {
+ ok(true, "Still alive \\o/");
+ SimpleTest.finish();
+ return "hello world";
+ }
+ });
+ }
+ });
+
+ SimpleTest.waitForExplicitFinish();
+
+</script>
+</body>
+</html>
diff --git a/dom/console/tests/test_bug979109.html b/dom/console/tests/test_bug979109.html
new file mode 100644
index 0000000000..dc3ee58149
--- /dev/null
+++ b/dom/console/tests/test_bug979109.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=979109
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 979109</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=979109">Mozilla Bug 979109</a>
+<script type="application/javascript">
+
+ console.warn("%", "a");
+ console.warn("%%", "a");
+ console.warn("%123", "a");
+ console.warn("%123.", "a");
+ console.warn("%123.123", "a");
+ console.warn("%123.123o", "a");
+ console.warn("%123.123s", "a");
+ console.warn("%123.123d", "a");
+ console.warn("%123.123f", "a");
+ console.warn("%123.123z", "a");
+ console.warn("%.", "a");
+ console.warn("%.123", "a");
+ ok(true, "Still alive \\o/");
+
+</script>
+</body>
+</html>
diff --git a/dom/console/tests/test_bug989665.html b/dom/console/tests/test_bug989665.html
new file mode 100644
index 0000000000..298274d7ae
--- /dev/null
+++ b/dom/console/tests/test_bug989665.html
@@ -0,0 +1,21 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=989665
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 989665</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=989665">Mozilla Bug 989665</a>
+<script type="application/javascript">
+
+w = new Worker("data:text/javascript;charset=UTF-8, console.log('%s', {toString: function() { throw 3 }}); ");
+ok(true, "This test should not crash.");
+
+</script>
+</body>
+</html>
diff --git a/dom/console/tests/test_console.xul b/dom/console/tests/test_console.xul
new file mode 100644
index 0000000000..4c34e2f46b
--- /dev/null
+++ b/dom/console/tests/test_console.xul
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<window title="Test for URL API"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <iframe id="iframe" />
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"><![CDATA[
+
+ ok("console" in window, "Console exists");
+ window.console.log(42);
+ ok("table" in console, "Console has the 'table' method.");
+ window.console = 42;
+ is(window.console, 42, "Console is replacable");
+
+ var frame = document.getElementById("iframe");
+ ok(frame, "Frame must exist");
+ frame.src="http://mochi.test:8888/tests/dom/console/test/file_empty.html";
+ frame.onload = function() {
+ ok("console" in frame.contentWindow, "Console exists in the iframe");
+ frame.contentWindow.console.log(42);
+ frame.contentWindow.console = 42;
+ is(frame.contentWindow.console, 42, "Console is replacable in the iframe");
+ SimpleTest.finish();
+ }
+
+ SimpleTest.waitForExplicitFinish();
+ ]]></script>
+</window>
diff --git a/dom/console/tests/test_consoleEmptyStack.html b/dom/console/tests/test_consoleEmptyStack.html
new file mode 100644
index 0000000000..be9dafb86c
--- /dev/null
+++ b/dom/console/tests/test_consoleEmptyStack.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="UTF-8">
+ <title>Test for empty stack in console</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">
+SimpleTest.waitForExplicitFinish();
+
+window.setTimeout(console.log.bind(console), 0, "xyz");
+
+window.addEventListener("fake", console.log.bind(console, "xyz"));
+
+window.addEventListener("fake", function() {
+ ok(true, "Still alive");
+ SimpleTest.finish();
+});
+
+window.dispatchEvent(new Event("fake"));
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/console/tests/test_console_binding.html b/dom/console/tests/test_console_binding.html
new file mode 100644
index 0000000000..764c9954ff
--- /dev/null
+++ b/dom/console/tests/test_console_binding.html
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Test Console binding</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() {
+ SpecialPowers.addObserver(this, "console-api-log-event", false);
+}
+
+var order = 0;
+consoleListener.prototype = {
+ observe: function(aSubject, aTopic, aData) {
+ if (aTopic == "console-api-log-event") {
+ var obj = aSubject.wrappedJSObject;
+ if (order+1 == parseInt(obj.arguments[0])) {
+ ok(true, "Message received: " + obj.arguments[0]);
+ order++;
+ }
+
+ if (order == 3) {
+ SpecialPowers.removeObserver(this, "console-api-log-event");
+ SimpleTest.finish();
+ return;
+ }
+ }
+ }
+}
+
+var cl = new consoleListener();
+SimpleTest.waitForExplicitFinish();
+
+[1,2,3].forEach(console.log);
+
+ </script>
+</body>
+</html>
diff --git a/dom/console/tests/test_console_proto.html b/dom/console/tests/test_console_proto.html
new file mode 100644
index 0000000000..b492a8926f
--- /dev/null
+++ b/dom/console/tests/test_console_proto.html
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Test for console.__proto__</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">
+
+ isnot(Object.getPrototypeOf(console), Object.prototype, "Foo");
+ is(Object.getPrototypeOf(Object.getPrototypeOf(console)), Object.prototype, "Boo");
+
+ </script>
+</body>
+</html>