Skip to content

Instantly share code, notes, and snippets.

@jimblandy
Created January 11, 2018 20:20
Show Gist options
  • Save jimblandy/b0cb13113b8e3067776f448f91ad01fc to your computer and use it in GitHub Desktop.
Save jimblandy/b0cb13113b8e3067776f448f91ad01fc to your computer and use it in GitHub Desktop.
Sample patch for a really lightweight devtools mochitest
diff --git a/devtools/server/tests/mochitest/chrome.ini b/devtools/server/tests/mochitest/chrome.ini
--- a/devtools/server/tests/mochitest/chrome.ini
+++ b/devtools/server/tests/mochitest/chrome.ini
@@ -18,16 +18,17 @@ support-files =
inspector-helpers.js
inspector-search-data.html
inspector-styles-data.css
inspector-styles-data.html
inspector-traversal-data.html
large-image.jpg
memory-helpers.js
nonchrome_unsafeDereference.html
+ nonchrome_suspendTimeouts.html
small-image.gif
setup-in-child.js
setup-in-parent.js
webconsole-helpers.js
webextension-helpers.js
[test_animation_actor-lifetime.html]
[test_connection-manager.html]
[test_connectToChild.html]
@@ -103,8 +104,9 @@ support-files =
[test_unsafeDereference.html]
[test_webconsole-node-grip.html]
[test_webextension-addon-debugging-connect.html]
skip-if = !e10s # test is designed to work on e10s only
[test_webextension-addon-debugging-reload.html]
skip-if = !e10s # test is designed to work on e10s only
[test_websocket-server.html]
skip-if = os == 'mac' # bug 1294873 intermittent leaks
+[test_suspendTimeouts.html]
diff --git a/devtools/server/tests/mochitest/nonchrome_suspendTimeouts.html b/devtools/server/tests/mochitest/nonchrome_suspendTimeouts.html
new file mode 100644
--- /dev/null
+++ b/devtools/server/tests/mochitest/nonchrome_suspendTimeouts.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML>
+<html>
+<script>
+"use strict";
+console.log("Look! A baby Balrog!");
+function child_fn() {
+ parent();
+}
+</script>
+</html>
diff --git a/devtools/server/tests/mochitest/test_suspendTimeouts.html b/devtools/server/tests/mochitest/test_suspendTimeouts.html
new file mode 100644
--- /dev/null
+++ b/devtools/server/tests/mochitest/test_suspendTimeouts.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1426467
+
+When we use windowUtils.resumeTimeouts to resume timeouts in a window, that call
+should not immediately dispatch `onmessage` handlers for messages from workers.
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Mozilla Bug 1426467</title>
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
+</head>
+<body>
+<pre id="test">
+<script>
+"use strict";
+
+window.onload = function () {
+ SimpleTest.waitForExplicitFinish();
+
+ let iframe = document.createElement("iframe");
+ iframe.src = "http://mochi.test:8888/chrome/devtools/server/tests/mochitest/nonchrome_suspendTimeouts.html";
+
+ iframe.onload = function () {
+ var child = iframe.contentWindow.wrappedJSObject;
+ child.parent = function () {
+ SimpleTest.info("Fresh spitunia, Julia!!");
+ }
+ SimpleTest.info("National Tautology Day? Well, you know. It is what it is.");
+ SimpleTest.info("typeof child_fn: " + typeof(child.child_fn));
+ SimpleTest.info("typeof Math: " + typeof(child.Math));
+ SimpleTest.info("toString: " + child.child_fn);
+ child.child_fn();
+ is('it is', 'what it is');
+ SimpleTest.finish();
+ };
+
+ document.body.appendChild(iframe);
+};
+
+</script>
+</pre>
+</body>
+</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment