Bug 1323941 - navigationStart should not be exposed to workers as timing attribute

https://hg.mozilla.org/mozilla-central/rev/6be7eb833b11
This commit is contained in:
janekptacijarabaci 2018-04-29 12:11:55 +02:00 • committed by Roy Tam
commit fdcf9f71e5
8 changed files with 71 additions and 40 deletions

View file

@ -123,10 +123,16 @@ protected:
virtual DOMHighResTimeStamp CreationTime() const = 0;
virtual bool IsPerformanceTimingAttribute(const nsAString& aName) = 0;
virtual bool IsPerformanceTimingAttribute(const nsAString& aName)
{
return false;
}
virtual DOMHighResTimeStamp
GetPerformanceTimingFromString(const nsAString& aTimingName) = 0;
GetPerformanceTimingFromString(const nsAString& aTimingName)
{
return 0;
}
bool IsResourceEntryLimitReached() const
{

View file

@ -31,29 +31,6 @@ PerformanceWorker::Now() const
return RoundTime(duration.ToMilliseconds());
}
// To be removed once bug 1124165 lands
bool
PerformanceWorker::IsPerformanceTimingAttribute(const nsAString& aName)
{
// In workers we just support navigationStart.
return aName.EqualsASCII("navigationStart");
}
DOMHighResTimeStamp
PerformanceWorker::GetPerformanceTimingFromString(const nsAString& aProperty)
{
if (!IsPerformanceTimingAttribute(aProperty)) {
return 0;
}
if (aProperty.EqualsLiteral("navigationStart")) {
return mWorkerPrivate->NowBaseTime();
}
MOZ_CRASH("IsPerformanceTimingAttribute and GetPerformanceTimingFromString are out of sync");
return 0;
}
void
PerformanceWorker::InsertUserEntry(PerformanceEntry* aEntry)
{

View file

@ -74,11 +74,6 @@ protected:
void InsertUserEntry(PerformanceEntry* aEntry) override;
bool IsPerformanceTimingAttribute(const nsAString& aName) override;
DOMHighResTimeStamp
GetPerformanceTimingFromString(const nsAString& aTimingName) override;
void DispatchBufferFullEvent() override
{
MOZ_CRASH("This should not be called on workers.");

View file

@ -126,15 +126,18 @@ var steps = [
},
// Test measure
function () {
ok(true, "Running measure addition with no start/end time test");
performance.measure("test");
var measures = performance.getEntriesByType("measure");
is(measures.length, 1, "number of measures should be 1");
var measure = measures[0];
is(measure.name, "test", "measure name should be 'test'");
is(measure.entryType, "measure", "measure type should be 'measure'");
is(measure.startTime, 0, "measure start time should be zero");
ok(measure.duration >= 0, "measure duration should not be negative");
// We don't have navigationStart in workers.
if ("window" in self) {
ok(true, "Running measure addition with no start/end time test");
performance.measure("test", "navigationStart");
var measures = performance.getEntriesByType("measure");
is(measures.length, 1, "number of measures should be 1");
var measure = measures[0];
is(measure.name, "test", "measure name should be 'test'");
is(measure.entryType, "measure", "measure type should be 'measure'");
is(measure.startTime, 0, "measure start time should be zero");
ok(measure.duration >= 0, "measure duration should not be negative");
}
},
function () {
ok(true, "Running measure addition with only start time test");