[dart:html] Fix Performance.mark typing to work with Firefox

Closes https://github.com/dart-lang/sdk/issues/48630

'mark' can return undefined in Firefox, and therefore needs to
return a nullable. Similarly, the different syntaxes of 'measure'
don't work in Firefox or Safari, so the incompatible ones are
removed from tests.

Change-Id: Ia137fe0d72ddbaad03ae8cf58c43736b128b3f33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237930
Reviewed-by: Riley Porter <rileyporter@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
Srujan Gaddam 2022-03-22 19:37:00 +00:00 committed by Commit Bot
parent 25f309fa54
commit 3f1c69dd1d
5 changed files with 10 additions and 13 deletions

View file

@ -30,7 +30,7 @@
- Change `Performance.mark` and `Performance.measure` to accept their different
overloads. `mark` can now accept a `markOptions` map, and `measure` can now
accept a `startMark` and `endMark`, or a `measureOptions` map. Both methods
return their correct return types now as well - `PerformanceEntry` and
return their correct return types now as well - `PerformanceEntry?` and
`PerformanceMeasure?`, respectively.
#### `dart:indexed_db`

View file

@ -25239,7 +25239,7 @@ class Performance extends EventTarget {
List<PerformanceEntry> getEntriesByType(String entryType) native;
PerformanceEntry mark(String markName, [Map? markOptions]) {
PerformanceEntry? mark(String markName, [Map? markOptions]) {
if (markOptions != null) {
var markOptions_1 = convertDartToNative_Dictionary(markOptions);
return _mark_1(markName, markOptions_1);
@ -25248,9 +25248,9 @@ class Performance extends EventTarget {
}
@JSName('mark')
PerformanceEntry _mark_1(markName, markOptions) native;
PerformanceEntry? _mark_1(markName, markOptions) native;
@JSName('mark')
PerformanceEntry _mark_2(markName) native;
PerformanceEntry? _mark_2(markName) native;
PerformanceMeasure? measure(String measureName,
[measureOptions_OR_startMark, String? endMark]) {

View file

@ -36,10 +36,6 @@ main() {
window.performance.measure('measure1');
window.performance.measure('measure2', 'mark1');
window.performance.measure('measure3', 'mark1', 'mark2');
window.performance.measure('measure4', null, 'mark2');
window.performance.measure('measure5', 'mark1', null);
window.performance.measure('measure6', null, null);
window.performance.measure('measure7', {'start': 'mark1'});
});
});
}

View file

@ -33,10 +33,6 @@ main() {
window.performance.measure('measure1');
window.performance.measure('measure2', 'mark1');
window.performance.measure('measure3', 'mark1', 'mark2');
window.performance.measure('measure4', null, 'mark2');
window.performance.measure('measure5', 'mark1', null);
window.performance.measure('measure6', null, null);
window.performance.measure('measure7', {'start': 'mark1'});
});
});
}

View file

@ -601,8 +601,13 @@ interface Performance {
[DartSuppress, Measure] readonly attribute MemoryInfo memory;
[Measure] readonly attribute MemoryInfo? memory;
[DartSuppress] void mark(DOMString markName);
PerformanceEntry mark(DOMString markName, optional Dictionary markOptions);
PerformanceEntry? mark(DOMString markName, optional Dictionary markOptions);
[DartSuppress] void measure(DOMString measureName, optional DOMString startMark = null, optional DOMString endMark = null);
// Note that `startMark` and `endMark` can't be null (but they can be
// undefined) in Firefox. Firefox also seems to disallow `measureOptions`.
// Safari also requires that `endMark` be non-null if `startMark` is
// non-null. In order to unify different browser behavior, we allow all
// possible syntaxes.
PerformanceMeasure? measure(DOMString measureName, optional DOMString? startMark, optional DOMString? endMark);
PerformanceMeasure? measure(DOMString measureName, Dictionary measureOptions);
};