From f9a6bbeab56a907f9ebeb3944edf12f9fcda5282 Mon Sep 17 00:00:00 2001 From: Jordan Santell Date: Wed, 18 Mar 2015 13:55:42 -0700 Subject: [PATCH] Bug 1143004 - markers from console.timeStamp() should be rendered in the performance tool's timeline. r=vp --- browser/devtools/performance/test/browser.ini | 1 + .../test/browser_markers-timestamp.js | 46 +++++++++++++++++++ browser/devtools/shared/timeline/global.js | 13 ++++-- .../browser/devtools/timeline.properties | 1 + .../shared/devtools/performance.inc.css | 7 ++- 5 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 browser/devtools/performance/test/browser_markers-timestamp.js diff --git a/browser/devtools/performance/test/browser.ini b/browser/devtools/performance/test/browser.ini index fde12ac2d6e..3022a44d03b 100644 --- a/browser/devtools/performance/test/browser.ini +++ b/browser/devtools/performance/test/browser.ini @@ -13,6 +13,7 @@ support-files = [browser_perf-aaa-run-first-leaktest.js] [browser_markers-gc.js] [browser_markers-parse-html.js] +[browser_markers-timestamp.js] [browser_perf-allocations-to-samples.js] [browser_perf-compatibility-01.js] [browser_perf-compatibility-02.js] diff --git a/browser/devtools/performance/test/browser_markers-timestamp.js b/browser/devtools/performance/test/browser_markers-timestamp.js new file mode 100644 index 00000000000..db46a354144 --- /dev/null +++ b/browser/devtools/performance/test/browser_markers-timestamp.js @@ -0,0 +1,46 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Test that we get a "TimeStamp" marker. + */ + +const TIME_CLOSE_TO = 10000; + +function* spawnTest () { + let { target, front } = yield initBackend(SIMPLE_URL); + loadFrameScripts(); + let markers = []; + + front.on("timeline-data", handler); + let model = yield front.startRecording({ withTicks: true }); + + consoleMethod("timeStamp"); + consoleMethod("timeStamp", "myLabel"); + yield waitUntil(() => { return markers.length === 2; }, 100); + + front.off("timeline-data", handler); + yield front.stopRecording(model); + + info(`Got ${markers.length} markers.`); + + let maxMarkerTime = model._timelineStartTime + model.getDuration() + TIME_CLOSE_TO; + + ok(markers.every(({name}) => name === "TimeStamp"), "All markers found are TimeStamp markers"); + ok(markers.length === 2, "found 2 TimeStamp markers"); + ok(markers.every(({start}) => typeof start === "number" && start > 0 && start < maxMarkerTime), + "All markers have a start time between the valid range."); + ok(markers.every(({end}) => typeof end === "number" && end > 0 && end < maxMarkerTime), + "All markers have an end time between the valid range."); + is(markers[0].causeName, void 0, "Unlabeled timestamps have an empty causeName"); + is(markers[1].causeName, "myLabel", "Labeled timestamps have correct causeName"); + + yield removeTab(target.tab); + finish(); + + function handler (_, name, m) { + if (name === "markers") { + markers = markers.concat(m.filter(marker => marker.name === "TimeStamp")); + } + } +} diff --git a/browser/devtools/shared/timeline/global.js b/browser/devtools/shared/timeline/global.js index 28ee3efe7b4..a5095c1efc9 100644 --- a/browser/devtools/shared/timeline/global.js +++ b/browser/devtools/shared/timeline/global.js @@ -64,15 +64,20 @@ const TIMELINE_BLUEPRINT = { colorName: "highlight-lightorange", label: L10N.getStr("timeline.label.parseXML") }, + "GarbageCollection": { + group: 1, + colorName: "highlight-red", + label: L10N.getStr("timeline.label.garbageCollection") + }, "ConsoleTime": { group: 2, colorName: "highlight-bluegrey", label: L10N.getStr("timeline.label.consoleTime") }, - "GarbageCollection": { - group: 1, - colorName: "highlight-red", - label: L10N.getStr("timeline.label.garbageCollection") + "TimeStamp": { + group: 2, + colorName: "highlight-purple", + label: L10N.getStr("timeline.label.timestamp") }, }; diff --git a/browser/locales/en-US/chrome/browser/devtools/timeline.properties b/browser/locales/en-US/chrome/browser/devtools/timeline.properties index fc11ada177a..77b745b39c1 100644 --- a/browser/locales/en-US/chrome/browser/devtools/timeline.properties +++ b/browser/locales/en-US/chrome/browser/devtools/timeline.properties @@ -45,6 +45,7 @@ timeline.label.parseXML=Parse XML timeline.label.domevent=DOM Event timeline.label.consoleTime=Console timeline.label.garbageCollection=GC Event +timeline.label.timestamp=Timestamp # LOCALIZATION NOTE (graphs.memory): # This string is displayed in the memory graph of the Performance tool, diff --git a/browser/themes/shared/devtools/performance.inc.css b/browser/themes/shared/devtools/performance.inc.css index afd66785573..2fc4e6ac454 100644 --- a/browser/themes/shared/devtools/performance.inc.css +++ b/browser/themes/shared/devtools/performance.inc.css @@ -503,7 +503,12 @@ .waterfall-marker-bullet.highlight-red { background-color: var(--theme-highlight-red); } - +#performance-filter-menupopup > menuitem.highlight-purple:before, +.marker-details-bullet.highlight-purple, +.waterfall-marker-bar.highlight-purple, +.waterfall-marker-bullet.highlight-purple { + background-color: var(--theme-highlight-purple); +} #waterfall-details > * { padding-top: 3px;