Backed out changeset 3cd097a7b017 (bug 1539006) for po-observe.any.worker.html failures CLOSED TREE

This commit is contained in:
Bogdan Tara 2019-04-10 09:48:56 +03:00
Родитель f9bbc9217b
Коммит 3b6c73d88a
14 изменённых файлов: 138 добавлений и 244 удалений

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

@ -358,8 +358,6 @@ AmbientLightEventWarning=Use of the ambient light sensor is deprecated.
IDBOpenDBOptions_StorageTypeWarning=The storage attribute in options passed to indexedDB.open is deprecated and will soon be removed. To get persistent storage, please use navigator.storage.persist() instead.
DOMQuadBoundsAttrWarning=DOMQuad.bounds is deprecated in favor of DOMQuad.getBounds()
UnsupportedEntryTypesIgnored=Ignoring unsupported entryTypes: %S.
# LOCALIZATION NOTE: Do not add a period at the end of this sentence. This string is used in UnsupportedEntryTypesIgnored, it will be preceded by a colon and followed by a period.
NoValidEntryTypes=No valid entry types; aborting registration
#LOCALIZATION NOTE(DeprecatedTestingInterfaceWarning): Do not translate this message. It's just testing only.
DeprecatedTestingInterfaceWarning=TestingDeprecatedInterface is a testing-only interface and this is its testing deprecation message.

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

@ -596,23 +596,8 @@ void Performance::QueueEntry(PerformanceEntry* aEntry) {
if (mObservers.IsEmpty()) {
return;
}
nsTObserverArray<PerformanceObserver*> interestedObservers;
nsTObserverArray<PerformanceObserver*>::ForwardIterator observerIt(
mObservers);
while (observerIt.HasMore()) {
PerformanceObserver* observer = observerIt.GetNext();
if (observer->ObservesTypeOfEntry(aEntry)) {
interestedObservers.AppendElement(observer);
}
}
if (interestedObservers.IsEmpty()) {
return;
}
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(
interestedObservers, PerformanceObserver, QueueEntry, (aEntry));
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mObservers, PerformanceObserver,
QueueEntry, (aEntry));
if (!mPendingNotificationObserversTask) {
RunNotificationObserversTask();

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

@ -48,17 +48,14 @@ NS_INTERFACE_MAP_END
PerformanceObserver::PerformanceObserver(nsPIDOMWindowInner* aOwner,
PerformanceObserverCallback& aCb)
: mOwner(aOwner),
mCallback(&aCb),
mObserverType(ObserverTypeUndefined),
mConnected(false) {
: mOwner(aOwner), mCallback(&aCb), mConnected(false) {
MOZ_ASSERT(mOwner);
mPerformance = aOwner->GetPerformance();
}
PerformanceObserver::PerformanceObserver(WorkerPrivate* aWorkerPrivate,
PerformanceObserverCallback& aCb)
: mCallback(&aCb), mObserverType(ObserverTypeUndefined), mConnected(false) {
: mCallback(&aCb), mConnected(false) {
MOZ_ASSERT(aWorkerPrivate);
mPerformance = aWorkerPrivate->GlobalScope()->GetPerformance();
}
@ -119,218 +116,87 @@ void PerformanceObserver::Notify() {
void PerformanceObserver::QueueEntry(PerformanceEntry* aEntry) {
MOZ_ASSERT(aEntry);
if (!ObservesTypeOfEntry(aEntry)) {
nsAutoString entryType;
aEntry->GetEntryType(entryType);
if (!mEntryTypes.Contains<nsString>(entryType)) {
return;
}
mQueuedEntries.AppendElement(aEntry);
}
/*
* Keep this list in alphabetical order.
* https://w3c.github.io/performance-timeline/#supportedentrytypes-attribute
*/
static const char16_t* const sValidTypeNames[4] = {
u"navigation",
u"mark",
u"measure",
u"navigation",
u"resource",
};
void PerformanceObserver::ReportUnsupportedTypesErrorToConsole(
bool aIsMainThread, const nsString& aInvalidTypes) {
if (!aIsMainThread) {
nsTArray<nsString> params;
params.AppendElement(aInvalidTypes);
WorkerPrivate::ReportErrorToConsole("UnsupportedEntryTypesIgnored", params);
} else {
nsCOMPtr<nsPIDOMWindowInner> ownerWindow = do_QueryInterface(mOwner);
Document* document = ownerWindow->GetExtantDoc();
const char16_t* params[] = {aInvalidTypes.get()};
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("DOM"), document,
nsContentUtils::eDOM_PROPERTIES,
"UnsupportedEntryTypesIgnored", params, 1);
}
return;
}
void PerformanceObserver::Observe(const PerformanceObserverInit& aOptions,
ErrorResult& aRv) {
const Optional<Sequence<nsString>>& maybeEntryTypes = aOptions.mEntryTypes;
const Optional<nsString>& maybeType = aOptions.mType;
const Optional<bool>& maybeBuffered = aOptions.mBuffered;
if (!maybeEntryTypes.WasPassed() && !maybeType.WasPassed()) {
/* Per spec (3.3.1.2), this should be a syntax error. */
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
void PerformanceObserver::Observe(const PerformanceObserverInit& aOptions) {
if (aOptions.mEntryTypes.IsEmpty()) {
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);
return;
nsTArray<nsString> validEntryTypes;
for (const char16_t* name : sValidTypeNames) {
nsDependentString validTypeName(name);
if (aOptions.mEntryTypes.Contains<nsString>(validTypeName) &&
!validEntryTypes.Contains<nsString>(validTypeName)) {
validEntryTypes.AppendElement(validTypeName);
}
}
/* 3.3.1.4.1 */
if (mObserverType == ObserverTypeUndefined) {
if (maybeEntryTypes.WasPassed()) {
mObserverType = ObserverTypeMultiple;
nsAutoString invalidTypesJoined;
bool addComma = false;
for (const auto& type : aOptions.mEntryTypes) {
if (!validEntryTypes.Contains<nsString>(type)) {
if (addComma) {
invalidTypesJoined.AppendLiteral(", ");
}
addComma = true;
invalidTypesJoined.Append(type);
}
}
if (!invalidTypesJoined.IsEmpty()) {
if (!NS_IsMainThread()) {
nsTArray<nsString> params;
params.AppendElement(invalidTypesJoined);
WorkerPrivate::ReportErrorToConsole("UnsupportedEntryTypesIgnored",
params);
} else {
mObserverType = ObserverTypeSingle;
nsCOMPtr<nsPIDOMWindowInner> ownerWindow = do_QueryInterface(mOwner);
Document* document = ownerWindow->GetExtantDoc();
const char16_t* params[] = {invalidTypesJoined.get()};
nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM"), document,
nsContentUtils::eDOM_PROPERTIES, "UnsupportedEntryTypesIgnored",
params, 1);
}
}
/* 3.3.1.4.2 */
if (mObserverType == ObserverTypeSingle && maybeEntryTypes.WasPassed()) {
aRv.Throw(NS_ERROR_DOM_INVALID_MODIFICATION_ERR);
return;
}
/* 3.3.1.4.3 */
if (mObserverType == ObserverTypeMultiple && maybeType.WasPassed()) {
aRv.Throw(NS_ERROR_DOM_INVALID_MODIFICATION_ERR);
if (validEntryTypes.IsEmpty()) {
return;
}
/* 3.3.1.5 */
if (mObserverType == ObserverTypeMultiple) {
const Sequence<nsString>& entryTypes = maybeEntryTypes.Value();
mEntryTypes.SwapElements(validEntryTypes);
if (entryTypes.IsEmpty()) {
return;
}
mPerformance->AddObserver(this);
/* 3.3.1.5.2 */
nsTArray<nsString> validEntryTypes;
for (const char16_t* name : sValidTypeNames) {
nsDependentString validTypeName(name);
if (entryTypes.Contains<nsString>(validTypeName) &&
!validEntryTypes.Contains<nsString>(validTypeName)) {
validEntryTypes.AppendElement(validTypeName);
}
}
nsAutoString invalidTypesJoined;
bool addComma = false;
for (const auto& type : entryTypes) {
if (!validEntryTypes.Contains<nsString>(type)) {
if (addComma) {
invalidTypesJoined.AppendLiteral(", ");
}
addComma = true;
invalidTypesJoined.Append(type);
}
}
if (!invalidTypesJoined.IsEmpty()) {
ReportUnsupportedTypesErrorToConsole(NS_IsMainThread(),
invalidTypesJoined);
}
/* 3.3.1.5.3 */
if (validEntryTypes.IsEmpty()) {
nsString errorString;
nsresult rv = nsContentUtils::GetLocalizedString(
nsContentUtils::eDOM_PROPERTIES, "NoValidEntryTypes", errorString);
NS_ENSURE_SUCCESS(rv, );
ReportUnsupportedTypesErrorToConsole(NS_IsMainThread(), errorString);
return;
}
/*
* Registered or not, we clear out the list of options, and start fresh
* with the one that we are using here. (3.3.1.5.4,5)
*/
mOptions.Clear();
mOptions.AppendElement(aOptions);
} else {
MOZ_ASSERT(mObserverType == ObserverTypeSingle);
bool typeValid = false;
nsString type = maybeType.Value();
/* 3.3.1.6.2 */
for (const char16_t* name : sValidTypeNames) {
nsDependentString validTypeName(name);
if (type == validTypeName) {
typeValid = true;
break;
}
}
if (!typeValid) {
ReportUnsupportedTypesErrorToConsole(NS_IsMainThread(), type);
return;
}
/* 3.3.1.6.4, 3.3.1.6.4 */
bool didUpdateOptionsList = false;
nsTArray<PerformanceObserverInit> updatedOptionsList;
for (auto& option : mOptions) {
if (option.mType.WasPassed() && option.mType.Value() == type) {
updatedOptionsList.AppendElement(aOptions);
didUpdateOptionsList = true;
} else {
updatedOptionsList.AppendElement(option);
}
}
if (!didUpdateOptionsList) {
updatedOptionsList.AppendElement(aOptions);
}
mOptions.SwapElements(updatedOptionsList);
/* 3.3.1.6.5 */
if (maybeBuffered.WasPassed() && maybeBuffered.Value()) {
if (aOptions.mBuffered) {
for (auto entryType : mEntryTypes) {
nsTArray<RefPtr<PerformanceEntry>> existingEntries;
mPerformance->GetEntriesByType(type, existingEntries);
mPerformance->GetEntriesByType(entryType, existingEntries);
if (!existingEntries.IsEmpty()) {
mQueuedEntries.AppendElements(existingEntries);
}
}
}
/* Add ourselves to the list of registered performance
* observers, if necessary. (3.3.1.5.4,5; 3.3.1.6.4)
*/
mPerformance->AddObserver(this);
mConnected = true;
}
void PerformanceObserver::GetSupportedEntryTypes(
const GlobalObject& aGlobal, JS::MutableHandle<JSObject*> aObject) {
nsTArray<nsString> validTypes;
JS::Rooted<JS::Value> val(aGlobal.Context());
for (const char16_t* name : sValidTypeNames) {
nsString validTypeName(name);
validTypes.AppendElement(validTypeName);
}
if (!ToJSValue(aGlobal.Context(), validTypes, &val)) {
/*
* If this conversion fails, we don't set a result.
* The spec does not allow us to throw an exception.
*/
return;
}
aObject.set(&val.toObject());
}
bool PerformanceObserver::ObservesTypeOfEntry(PerformanceEntry* aEntry) {
for (auto& option : mOptions) {
if (option.mType.WasPassed()) {
if (option.mType.Value() == aEntry->GetEntryType()) {
return true;
}
} else {
if (option.mEntryTypes.Value().Contains(aEntry->GetEntryType())) {
return true;
}
}
}
return false;
}
void PerformanceObserver::Disconnect() {
if (mConnected) {
MOZ_ASSERT(mPerformance);

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

@ -49,9 +49,7 @@ class PerformanceObserver final : public nsISupports, public nsWrapperCache {
nsISupports* GetParentObject() const { return mOwner; }
void Observe(const PerformanceObserverInit& aOptions, ErrorResult& aRv);
static void GetSupportedEntryTypes(const GlobalObject& aGlobal,
JS::MutableHandle<JSObject*> aObject);
void Observe(const PerformanceObserverInit& aOptions);
void Disconnect();
@ -60,26 +58,13 @@ class PerformanceObserver final : public nsISupports, public nsWrapperCache {
MOZ_CAN_RUN_SCRIPT void Notify();
void QueueEntry(PerformanceEntry* aEntry);
bool ObservesTypeOfEntry(PerformanceEntry* aEntry);
private:
void ReportUnsupportedTypesErrorToConsole(bool aIsMainThread,
const nsString& aInvalidTypes);
~PerformanceObserver();
nsCOMPtr<nsISupports> mOwner;
RefPtr<PerformanceObserverCallback> mCallback;
RefPtr<Performance> mPerformance;
nsTArray<nsString> mEntryTypes;
nsTArray<PerformanceObserverInit> mOptions;
enum {
ObserverTypeUndefined,
ObserverTypeSingle,
ObserverTypeMultiple,
} mObserverType;
/*
* This is also known as registered, in the spec.
*/
bool mConnected;
nsTArray<RefPtr<PerformanceEntry>> mQueuedEntries;
};

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

@ -12,11 +12,11 @@ test(t => {
var observer = new PerformanceObserver(() => {
});
assert_throws({name: "SyntaxError"}, function() {
assert_throws({name: "TypeError"}, function() {
observer.observe();
}, "observe() should throw TypeError exception if no option specified.");
assert_throws({name: "SyntaxError"}, function() {
assert_throws({name: "TypeError"}, function() {
observer.observe({ unsupportedAttribute: "unsupported" });
}, "obsrve() should throw TypeError exception if the option has no 'entryTypes' attribute.");

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

@ -8,9 +8,8 @@
*/
dictionary PerformanceObserverInit {
sequence<DOMString> entryTypes;
DOMString type;
boolean buffered;
required sequence<DOMString> entryTypes;
boolean buffered = false;
};
callback PerformanceObserverCallback = void (PerformanceObserverEntryList entries,
@ -20,8 +19,7 @@ callback PerformanceObserverCallback = void (PerformanceObserverEntryList entrie
Constructor(PerformanceObserverCallback callback),
Exposed=(Window,Worker)]
interface PerformanceObserver {
[Throws] void observe(optional PerformanceObserverInit options);
void observe(PerformanceObserverInit options);
void disconnect();
PerformanceEntryList takeRecords();
static readonly attribute object supportedEntryTypes;
};

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

@ -0,0 +1,4 @@
[supported_navigation_type.window.html]
[supportedEntryTypes contains 'navigation'.]
expected: FAIL

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

@ -2,10 +2,7 @@
expected: TIMEOUT
[idlharness.any.serviceworker.html]
[PerformanceObserver interface: calling observe(PerformanceObserverInit) on observer with too few arguments must throw TypeError]
expected: FAIL
[PerformanceObserver interface: operation observe(PerformanceObserverInit)]
[PerformanceObserver interface: attribute supportedEntryTypes]
expected: FAIL
[PerformanceMark interface: attribute detail]
@ -19,13 +16,10 @@
[idlharness.any.sharedworker.html]
[PerformanceMark interface: attribute detail]
[PerformanceObserver interface: attribute supportedEntryTypes]
expected: FAIL
[PerformanceObserver interface: calling observe(PerformanceObserverInit) on observer with too few arguments must throw TypeError]
expected: FAIL
[PerformanceObserver interface: operation observe(PerformanceObserverInit)]
[PerformanceMark interface: attribute detail]
expected: FAIL
[PerformanceMark interface: mark must inherit property "detail" with the proper type]
@ -36,13 +30,10 @@
[idlharness.any.html]
[PerformanceMark interface: attribute detail]
[PerformanceObserver interface: attribute supportedEntryTypes]
expected: FAIL
[PerformanceObserver interface: calling observe(PerformanceObserverInit) on observer with too few arguments must throw TypeError]
expected: FAIL
[PerformanceObserver interface: operation observe(PerformanceObserverInit)]
[PerformanceMark interface: attribute detail]
expected: FAIL
[PerformanceMark interface: mark must inherit property "detail" with the proper type]
@ -53,13 +44,10 @@
[idlharness.any.worker.html]
[PerformanceMark interface: attribute detail]
[PerformanceObserver interface: attribute supportedEntryTypes]
expected: FAIL
[PerformanceObserver interface: calling observe(PerformanceObserverInit) on observer with too few arguments must throw TypeError]
expected: FAIL
[PerformanceObserver interface: operation observe(PerformanceObserverInit)]
[PerformanceMark interface: attribute detail]
expected: FAIL
[PerformanceMark interface: mark must inherit property "detail" with the proper type]

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

@ -0,0 +1,33 @@
[po-observe-type.any.html]
[Calling observe() with entryTypes and then type should throw an InvalidModificationError]
expected: FAIL
[Calling observe() with type and then entryTypes should throw an InvalidModificationError]
expected: FAIL
[Calling observe() with type and entryTypes should throw a SyntaxError]
expected: FAIL
[Passing in unknown values to type does throw an exception.]
expected: FAIL
[observe() with different type values stacks.]
expected: FAIL
[po-observe-type.any.worker.html]
[Calling observe() with entryTypes and then type should throw an InvalidModificationError]
expected: FAIL
[Calling observe() with type and then entryTypes should throw an InvalidModificationError]
expected: FAIL
[Calling observe() with type and entryTypes should throw a SyntaxError]
expected: FAIL
[Passing in unknown values to type does throw an exception.]
expected: FAIL
[observe() with different type values stacks.]
expected: FAIL

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

@ -0,0 +1,9 @@
[po-observe.any.html]
[no 'type' or 'entryTypes' throws a SyntaxError]
expected: FAIL
[po-observe.any.worker.html]
[no 'type' or 'entryTypes' throws a SyntaxError]
expected: FAIL

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

@ -2,3 +2,4 @@
expected: ERROR
[PerformanceObserverInit.buffered should retrieve previously buffered entries]
expected: TIMEOUT

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

@ -0,0 +1,9 @@
[supportedEntryTypes.any.html]
[supportedEntryTypes exists and returns entries in alphabetical order]
expected: FAIL
[supportedEntryTypes.any.worker.html]
[supportedEntryTypes exists and returns entries in alphabetical order]
expected: FAIL

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

@ -0,0 +1,9 @@
[supported_resource_type.any.html]
[supportedEntryTypes contains 'resource'.]
expected: FAIL
[supported_resource_type.any.worker.html]
[supportedEntryTypes contains 'resource'.]
expected: FAIL

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

@ -0,0 +1,9 @@
[supported-usertiming-types.any.html]
[supportedEntryTypes contains 'mark' and 'measure'.]
expected: FAIL
[supported-usertiming-types.any.worker.html]
[supportedEntryTypes contains 'mark' and 'measure'.]
expected: FAIL