summaryrefslogtreecommitdiffstats
path: root/docshell/test/browser/browser_timelineMarkers-frame-04.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-04.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-04.js')
-rw-r--r--docshell/test/browser/browser_timelineMarkers-frame-04.js88
1 files changed, 88 insertions, 0 deletions
diff --git a/docshell/test/browser/browser_timelineMarkers-frame-04.js b/docshell/test/browser/browser_timelineMarkers-frame-04.js
new file mode 100644
index 000000000..427312993
--- /dev/null
+++ b/docshell/test/browser/browser_timelineMarkers-frame-04.js
@@ -0,0 +1,88 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Test that the docShell profile timeline API returns the right
+// markers for XMLHttpRequest events.
+
+var TESTS = [{
+ desc: "Event dispatch from XMLHttpRequest",
+ searchFor: function(markers) {
+ return markers.filter(m => m.name == "DOMEvent").length >= 5;
+ },
+ setup: function(docShell) {
+ content.dispatchEvent(new content.Event("dog"));
+ },
+ check: function(markers) {
+ let domMarkers = markers.filter(m => m.name == "DOMEvent");
+ // One subtlety here is that we have five events: the event we
+ // inject in "setup", plus the four state transition events. The
+ // first state transition is reported synchronously and so should
+ // show up as a nested marker.
+ is(domMarkers.length, 5, "Got 5 markers");
+
+ // We should see some Javascript markers, and they should have a
+ // cause.
+ let jsMarkers = markers.filter(m => m.name == "Javascript" && m.causeName);
+ ok(jsMarkers.length > 0, "Got some Javascript markers");
+ is(jsMarkers[0].stack.functionDisplayName, "do_xhr",
+ "Javascript marker has entry point name");
+ }
+}];
+
+if (Services.prefs.getBoolPref("javascript.options.asyncstack")) {
+ TESTS.push({
+ desc: "Async stack trace on Javascript marker",
+ searchFor: (markers) => {
+ return markers.some(m => (m.name == "Javascript" &&
+ m.causeName == "promise callback"));
+ },
+ setup: function(docShell) {
+ content.dispatchEvent(new content.Event("promisetest"));
+ },
+ check: function(markers) {
+ markers = markers.filter(m => (m.name == "Javascript" &&
+ m.causeName == "promise callback"));
+ ok(markers.length > 0, "Found a Javascript marker");
+
+ let frame = markers[0].stack;
+ ok(frame.asyncParent !== null, "Parent frame has async parent");
+ is(frame.asyncParent.asyncCause, "promise callback",
+ "Async parent has correct cause");
+ let asyncFrame = frame.asyncParent;
+ // Skip over self-hosted parts of our Promise implementation.
+ while (asyncFrame.source === 'self-hosted')
+ asyncFrame = asyncFrame.parent;
+ is(asyncFrame.functionDisplayName, "do_promise",
+ "Async parent has correct function name");
+ }
+ }, {
+ desc: "Async stack trace on Javascript marker with script",
+ searchFor: (markers) => {
+ return markers.some(m => (m.name == "Javascript" &&
+ m.causeName == "promise callback"));
+ },
+ setup: function(docShell) {
+ content.dispatchEvent(new content.Event("promisescript"));
+ },
+ check: function(markers) {
+ markers = markers.filter(m => (m.name == "Javascript" &&
+ m.causeName == "promise callback"));
+ ok(markers.length > 0, "Found a Javascript marker");
+
+ let frame = markers[0].stack;
+ ok(frame.asyncParent !== null, "Parent frame has async parent");
+ is(frame.asyncParent.asyncCause, "promise callback",
+ "Async parent has correct cause");
+ let asyncFrame = frame.asyncParent;
+ // Skip over self-hosted parts of our Promise implementation.
+ while (asyncFrame.source === 'self-hosted')
+ asyncFrame = asyncFrame.parent;
+ is(asyncFrame.functionDisplayName, "do_promise_script",
+ "Async parent has correct function name");
+ }
+ });
+}
+
+timelineContentTest(TESTS);