Skip to content

Commit

Permalink
Bug 1462879 - Performance.getEntriesByName must consider the Performa…
Browse files Browse the repository at this point in the history
…nceNavigationTiming name, r=valentin
  • Loading branch information
bakulf committed May 24, 2018
1 parent 687c271 commit f87bd4e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
12 changes: 5 additions & 7 deletions dom/performance/PerformanceMainThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,16 +393,14 @@ PerformanceMainThread::GetEntriesByName(const nsAString& aName,
return;
}

if (aName.EqualsLiteral("document")) {
aRetval.Clear();
Performance::GetEntriesByName(aName, aEntryType, aRetval);

if (mDocEntry) {
aRetval.AppendElement(mDocEntry);
}
// The navigation entry is the first one. If it exists and the name matches,
// let put it in front.
if (mDocEntry && mDocEntry->GetName().Equals(aName)) {
aRetval.InsertElementAt(0, mDocEntry);
return;
}

Performance::GetEntriesByName(aName, aEntryType, aRetval);
}

} // dom namespace
Expand Down
7 changes: 4 additions & 3 deletions dom/tests/mochitest/general/resource_timing_iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
window.parent.ok(!!window.performance.getEntriesByName(
"http://mochi.test:8888/tests/image/test/mochitest/damon.jpg").length,
"http://mochi.test:8888/tests/image/test/mochitest/damon.jpg should be a valid entry name");
window.parent.ok(!window.performance.getEntriesByName(
"http://mochi.test:8888/tests/dom/tests/mochitest/general/resource_timing_iframe.html").length,
"This iframe should NOT contain itself as an entry");
var entries = window.performance.getEntriesByName(
"http://mochi.test:8888/tests/dom/tests/mochitest/general/resource_timing_iframe.html");
window.parent.ok(entries.length == 1, "This iframe should contain itself only once");
window.parent.ok(entries[0].type == "navigate", "This iframe should contain itself only once and it must be a navigation entry");

// Check that there are no iframes added as entries
var resources = window.performance.getEntriesByType("resource");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
SpecialPowers.pushPrefEnv({"set": [["dom.enable_performance_navigation_timing", true]]}, start);

function start() {
var p = performance.getEntriesByName("document")[0];
ok(!!p, "There should be an entry for the document");
var p = performance.getEntriesByName(window.location.toString())[0];
ok(!!p, "There should be an entry for this URL");
document.getElementById("content").textContent += JSON.stringify(p);

SimpleTest.finish();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
prefs: [privacy.reduceTimerPrecision:false]
[nav2_test_redirect_server.html]
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ <h1>Description</h1>
t.step_func(function (entryList) {
var instance1 = performance.getEntries()[0];
var instance2 = performance.getEntriesByType("navigation")[0];
var instance3 = performance.getEntriesByName("http://web-platform.test:8001/navigation-timing/nav2_test_instance_accessors.html")[0];
var instance3 = performance.getEntriesByName(window.location.toString())[0];

assert_equals(performance.getEntriesByType("navigation").length, 1, "Expected there is only one navigation timing instance.");
assert_equals(performance.getEntriesByName("http://web-platform.test:8001/navigation-timing/nav2_test_instance_accessors.html").length, 1, "Expected there is only one navigation timing instance.");
assert_equals(performance.getEntriesByName(window.location.toString()).length, 1, "Expected there is only one navigation timing instance.");

for (var i = 0; i < navTiming2Attributes.length; i++) {
assert_equals(instance1[navTiming2Attributes[i]], instance2[navTiming2Attributes[i]]);
Expand Down

0 comments on commit f87bd4e

Please sign in to comment.