mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-29 10:37:33 +09:00
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:
parent
dbccb9748a
commit
fdcf9f71e5
8 changed files with 71 additions and 40 deletions
|
|
@ -123,10 +123,16 @@ protected:
|
||||||
|
|
||||||
virtual DOMHighResTimeStamp CreationTime() const = 0;
|
virtual DOMHighResTimeStamp CreationTime() const = 0;
|
||||||
|
|
||||||
virtual bool IsPerformanceTimingAttribute(const nsAString& aName) = 0;
|
virtual bool IsPerformanceTimingAttribute(const nsAString& aName)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
virtual DOMHighResTimeStamp
|
virtual DOMHighResTimeStamp
|
||||||
GetPerformanceTimingFromString(const nsAString& aTimingName) = 0;
|
GetPerformanceTimingFromString(const nsAString& aTimingName)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsResourceEntryLimitReached() const
|
bool IsResourceEntryLimitReached() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -31,29 +31,6 @@ PerformanceWorker::Now() const
|
||||||
return RoundTime(duration.ToMilliseconds());
|
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
|
void
|
||||||
PerformanceWorker::InsertUserEntry(PerformanceEntry* aEntry)
|
PerformanceWorker::InsertUserEntry(PerformanceEntry* aEntry)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -74,11 +74,6 @@ protected:
|
||||||
|
|
||||||
void InsertUserEntry(PerformanceEntry* aEntry) override;
|
void InsertUserEntry(PerformanceEntry* aEntry) override;
|
||||||
|
|
||||||
bool IsPerformanceTimingAttribute(const nsAString& aName) override;
|
|
||||||
|
|
||||||
DOMHighResTimeStamp
|
|
||||||
GetPerformanceTimingFromString(const nsAString& aTimingName) override;
|
|
||||||
|
|
||||||
void DispatchBufferFullEvent() override
|
void DispatchBufferFullEvent() override
|
||||||
{
|
{
|
||||||
MOZ_CRASH("This should not be called on workers.");
|
MOZ_CRASH("This should not be called on workers.");
|
||||||
|
|
|
||||||
|
|
@ -126,15 +126,18 @@ var steps = [
|
||||||
},
|
},
|
||||||
// Test measure
|
// Test measure
|
||||||
function () {
|
function () {
|
||||||
ok(true, "Running measure addition with no start/end time test");
|
// We don't have navigationStart in workers.
|
||||||
performance.measure("test");
|
if ("window" in self) {
|
||||||
var measures = performance.getEntriesByType("measure");
|
ok(true, "Running measure addition with no start/end time test");
|
||||||
is(measures.length, 1, "number of measures should be 1");
|
performance.measure("test", "navigationStart");
|
||||||
var measure = measures[0];
|
var measures = performance.getEntriesByType("measure");
|
||||||
is(measure.name, "test", "measure name should be 'test'");
|
is(measures.length, 1, "number of measures should be 1");
|
||||||
is(measure.entryType, "measure", "measure type should be 'measure'");
|
var measure = measures[0];
|
||||||
is(measure.startTime, 0, "measure start time should be zero");
|
is(measure.name, "test", "measure name should be 'test'");
|
||||||
ok(measure.duration >= 0, "measure duration should not be negative");
|
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 () {
|
function () {
|
||||||
ok(true, "Running measure addition with only start time test");
|
ok(true, "Running measure addition with only start time test");
|
||||||
|
|
|
||||||
|
|
@ -31099,6 +31099,10 @@
|
||||||
"path": "user-timing/test_user_timing_mark.html",
|
"path": "user-timing/test_user_timing_mark.html",
|
||||||
"url": "/user-timing/test_user_timing_mark.html"
|
"url": "/user-timing/test_user_timing_mark.html"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "user-timing/test_user_timing_mark_and_measure_exception_when_invoke_with_timing_attributes.html",
|
||||||
|
"url": "/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_with_timing_attributes.html"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "user-timing/test_user_timing_mark_and_measure_exception_when_invoke_without_parameter.html",
|
"path": "user-timing/test_user_timing_mark_and_measure_exception_when_invoke_without_parameter.html",
|
||||||
"url": "/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_without_parameter.html"
|
"url": "/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_without_parameter.html"
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ policies and contribution forms [3].
|
||||||
// Helper Functions for NavigationTiming W3C tests
|
// Helper Functions for NavigationTiming W3C tests
|
||||||
//
|
//
|
||||||
|
|
||||||
var performanceNamespace = window.performance;
|
var performanceNamespace = self.performance;
|
||||||
var timingAttributes = [
|
var timingAttributes = [
|
||||||
'connectEnd',
|
'connectEnd',
|
||||||
'connectStart',
|
'connectStart',
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>exception test of performance.mark and performance.measure</title>
|
||||||
|
<meta rel="help" href="http://www.w3.org/TR/user-timing/#extensions-performance-interface"/>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="resources/webperftestharness.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
setup({explicit_done: true});
|
||||||
|
test_namespace();
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
for (var i in timingAttributes) {
|
||||||
|
assert_throws("SyntaxError", function() { window.performance.mark(timingAttributes[i]); });
|
||||||
|
assert_throws("SyntaxError", function() { window.performance.measure(timingAttributes[i]); });
|
||||||
|
}
|
||||||
|
}, "performance.mark and performance.measure should throw if used with timing attribute values");
|
||||||
|
|
||||||
|
fetch_tests_from_worker(new Worker("test_user_timing_mark_and_measure_exception_when_invoke_with_timing_attributes.js"));
|
||||||
|
|
||||||
|
done();
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<h1>Description</h1>
|
||||||
|
<p>This test validates exception scenarios of invoking mark() and measure() with timing attributes as value.</p>
|
||||||
|
<div id="log"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
importScripts("/resources/testharness.js");
|
||||||
|
importScripts("resources/webperftestharness.js");
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
for (var i in timingAttributes) {
|
||||||
|
performance.mark(timingAttributes[i]);
|
||||||
|
performance.clearMarks(timingAttributes[i]);
|
||||||
|
|
||||||
|
performance.measure(timingAttributes[i]);
|
||||||
|
performance.clearMeasures(timingAttributes[i]);
|
||||||
|
}
|
||||||
|
}, "performance.mark and performance.measure should not throw if used with timing attribute values in workers");
|
||||||
|
|
||||||
|
done();
|
||||||
Loading…
Add table
Add a link
Reference in a new issue