Bug 1444150 Performance.measure(name) should not throw if name is one of the readonly attribute of the Performance interface, r=valentin

This commit is contained in:
Andrea Marchesini 2018-03-09 08:23:44 +01:00
Родитель d5b6e21206
Коммит 9cfc993eff
4 изменённых файлов: 9 добавлений и 20 удалений

Просмотреть файл

@ -254,7 +254,6 @@ Performance::ResolveTimestampFromName(const nsAString& aName,
ErrorResult& aRv)
{
AutoTArray<RefPtr<PerformanceEntry>, 1> arr;
DOMHighResTimeStamp ts;
Optional<nsAString> typeParam;
nsAutoString str;
str.AssignLiteral("mark");
@ -269,7 +268,7 @@ Performance::ResolveTimestampFromName(const nsAString& aName,
return 0;
}
ts = GetPerformanceTimingFromString(aName);
DOMHighResTimeStamp ts = GetPerformanceTimingFromString(aName);
if (!ts) {
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
return 0;
@ -292,11 +291,6 @@ Performance::Measure(const nsAString& aName,
DOMHighResTimeStamp startTime;
DOMHighResTimeStamp endTime;
if (IsPerformanceTimingAttribute(aName)) {
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
return;
}
if (aStartMark.WasPassed()) {
startTime = ResolveTimestampFromName(aStartMark.Value(), aRv);
if (NS_WARN_IF(aRv.Failed())) {

Просмотреть файл

@ -241,17 +241,12 @@ var steps = [
function () {
ok(true, "Running measure name collision test");
for (n in performance.timing) {
try {
if (n == "toJSON") {
ok(true, "Skipping toJSON entry in collision test");
continue;
}
performance.measure(n);
ok(false, "Measure name collision test failed for name " + n + ", shouldn't make it here!");
} catch (e) {
ok(e instanceof DOMException, "DOM exception thrown for measure named " + n);
is(e.code, e.SYNTAX_ERR, "DOM exception for name collision is syntax error");
if (n == "toJSON") {
ok(true, "Skipping toJSON entry in collision test");
continue;
}
performance.measure(n);
ok(true, "Measure name supports name collisions: " + n);
};
},
// Test measure mark being a reserved name

Просмотреть файл

@ -24,8 +24,8 @@ for (var i in timingAttributes) {
function emit_test2(attrName) {
test(function() {
assert_throws("SyntaxError", function() { window.performance.measure(attrName); });
}, "performance.measure should throw if used with timing attribute " + attrName);
window.performance.measure(attrName);
}, "performance.measure should not throw if used with timing attribute " + attrName);
}
for (var i in timingAttributes) {
emit_test2(timingAttributes[i]);

Просмотреть файл

@ -59,7 +59,7 @@ test(function () {
"attribute with a value of 0, throws a InvalidAccessError exception.");
</script>
</head>
<body onload="onload_test();">
<body>
<h1>Description</h1>
<p><code>window.performance.measure()</code> method throws a InvalidAccessError
whenever a navigation timing attribute with a value of zero is provided as the startMark or endMark.