summaryrefslogtreecommitdiffstats
path: root/docshell/test/browser/browser_timelineMarkers-frame-05.js
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 /docshell/test/browser/browser_timelineMarkers-frame-05.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'docshell/test/browser/browser_timelineMarkers-frame-05.js')
-rw-r--r--docshell/test/browser/browser_timelineMarkers-frame-05.js117
1 files changed, 117 insertions, 0 deletions
diff --git a/docshell/test/browser/browser_timelineMarkers-frame-05.js b/docshell/test/browser/browser_timelineMarkers-frame-05.js
new file mode 100644
index 000000000..713f0e560
--- /dev/null
+++ b/docshell/test/browser/browser_timelineMarkers-frame-05.js
@@ -0,0 +1,117 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+function forceSyncReflow(div) {
+ div.setAttribute('class', 'resize-change-color');
+ // Force a reflow.
+ return div.offsetWidth;
+}
+
+function testSendingEvent() {
+ content.document.body.dispatchEvent(new content.Event("dog"));
+}
+
+function testConsoleTime() {
+ content.console.time("cats");
+}
+
+function testConsoleTimeEnd() {
+ content.console.timeEnd("cats");
+}
+
+function makePromise() {
+ let resolver;
+ new Promise(function(resolve, reject) {
+ testConsoleTime();
+ resolver = resolve;
+ }).then(function(val) {
+ testConsoleTimeEnd();
+ });
+ return resolver;
+}
+
+function resolvePromise(resolver) {
+ resolver(23);
+}
+
+var TESTS = [{
+ desc: "Stack trace on sync reflow",
+ searchFor: "Reflow",
+ setup: function(docShell) {
+ let div = content.document.querySelector("div");
+ forceSyncReflow(div);
+ },
+ check: function(markers) {
+ markers = markers.filter(m => m.name == "Reflow");
+ ok(markers.length > 0, "Reflow marker includes stack");
+ ok(markers[0].stack.functionDisplayName == "forceSyncReflow");
+ }
+}, {
+ desc: "Stack trace on DOM event",
+ searchFor: "DOMEvent",
+ setup: function(docShell) {
+ content.document.body.addEventListener("dog",
+ function(e) { console.log("hi"); },
+ true);
+ testSendingEvent();
+ },
+ check: function(markers) {
+ markers = markers.filter(m => m.name == "DOMEvent");
+ ok(markers.length > 0, "DOMEvent marker includes stack");
+ ok(markers[0].stack.functionDisplayName == "testSendingEvent",
+ "testSendingEvent is on the stack");
+ }
+}, {
+ desc: "Stack trace on console event",
+ searchFor: "ConsoleTime",
+ setup: function(docShell) {
+ testConsoleTime();
+ testConsoleTimeEnd();
+ },
+ check: function(markers) {
+ markers = markers.filter(m => m.name == "ConsoleTime");
+ ok(markers.length > 0, "ConsoleTime marker includes stack");
+ ok(markers[0].stack.functionDisplayName == "testConsoleTime",
+ "testConsoleTime is on the stack");
+ ok(markers[0].endStack.functionDisplayName == "testConsoleTimeEnd",
+ "testConsoleTimeEnd is on the stack");
+ }
+}];
+
+if (Services.prefs.getBoolPref("javascript.options.asyncstack")) {
+ TESTS.push({
+ desc: "Async stack trace on Promise",
+ searchFor: "ConsoleTime",
+ setup: function(docShell) {
+ let resolver = makePromise();
+ resolvePromise(resolver);
+ },
+ check: function(markers) {
+ markers = markers.filter(m => m.name == "ConsoleTime");
+ ok(markers.length > 0, "Promise marker includes stack");
+ ok(markers[0].stack.functionDisplayName == "testConsoleTime",
+ "testConsoleTime is on the stack");
+ let frame = markers[0].endStack;
+ ok(frame.functionDisplayName == "testConsoleTimeEnd",
+ "testConsoleTimeEnd is on the stack");
+
+ frame = frame.parent;
+ ok(frame.functionDisplayName == "makePromise/<",
+ "makePromise/< is on the stack");
+ let asyncFrame = frame.asyncParent;
+ ok(asyncFrame !== null, "Frame has async parent");
+ is(asyncFrame.asyncCause, "promise callback",
+ "Async parent has correct cause");
+ // Skip over self-hosted parts of our Promise implementation.
+ while (asyncFrame.source === 'self-hosted') {
+ asyncFrame = asyncFrame.parent;
+ }
+ is(asyncFrame.functionDisplayName, "makePromise",
+ "Async parent has correct function name");
+ }
+ });
+}
+
+timelineContentTest(TESTS);