Bug 1695328 - PerformanceObserver should throw TypeError instead of SyntaxError r=smaug

According to the latest spec
https://w3c.github.io/performance-timeline/#observe-method,
TypeError should be thrown, however we throw SyntaxError.

Differential Revision: https://phabricator.services.mozilla.com/D106669
This commit is contained in:
Sean Feng 2021-03-01 21:45:59 +00:00
Родитель 4d56684865
Коммит 04790aa069
3 изменённых файлов: 4 добавлений и 19 удалений

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

@ -164,14 +164,14 @@ void PerformanceObserver::Observe(const PerformanceObserverInit& aOptions,
if (!maybeEntryTypes.WasPassed() && !maybeType.WasPassed()) {
/* Per spec (3.3.1.2), this should be a syntax error. */
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
aRv.ThrowTypeError("Can't call observe without `type` or `entryTypes`");
return;
}
if (maybeEntryTypes.WasPassed() &&
(maybeType.WasPassed() || maybeBuffered.WasPassed())) {
/* Per spec (3.3.1.3), this, too, should be a syntax error. */
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
aRv.ThrowTypeError("Can't call observe with both `type` and `entryTypes`");
return;
}

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

@ -20,7 +20,7 @@ test(t => {
var observer = new PerformanceObserver(() => {});
assert_throws(
{ name: "SyntaxError" },
{ name: "TypeError" },
function() {
observer.observe();
},
@ -28,7 +28,7 @@ test(t => {
);
assert_throws(
{ name: "SyntaxError" },
{ name: "TypeError" },
function() {
observer.observe({ unsupportedAttribute: "unsupported" });
},

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

@ -1,15 +0,0 @@
[po-observe-type.any.html]
[Calling observe() with type and entryTypes should throw a TypeError]
expected: FAIL
[Calling observe() without 'type' or 'entryTypes' throws a TypeError]
expected: FAIL
[po-observe-type.any.worker.html]
[Calling observe() with type and entryTypes should throw a TypeError]
expected: FAIL
[Calling observe() without 'type' or 'entryTypes' throws a TypeError]
expected: FAIL