dart-sdk/tests/lib/html/performance_api_test.dart
Srujan Gaddam 3f1c69dd1d [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>
2022-03-22 19:37:00 +00:00

42 lines
1.5 KiB
Dart

// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:html';
import 'package:expect/minitest.dart';
main() {
group('supported', () {
test('supported', () {
expect(Performance.supported, true);
});
});
group('performance', () {
test('PerformanceApi', () {
// Check that code below will not throw exceptions if supported.
var expectation = Performance.supported ? returnsNormally : throws;
expect(() {
var requestStart = window.performance.timing.requestStart;
var responseStart = window.performance.timing.responseStart;
var responseEnd = window.performance.timing.responseEnd;
var loading = window.performance.timing.domLoading;
var loadedStart = window.performance.timing.domContentLoadedEventStart;
var loadedEnd = window.performance.timing.domContentLoadedEventEnd;
var complete = window.performance.timing.domComplete;
var loadEventStart = window.performance.timing.loadEventStart;
}, expectation);
});
test('markAndMeasure', () {
window.performance.mark('mark1');
window.performance.mark('mark2', {'detail': 'metadata'});
window.performance.measure('measure1');
window.performance.measure('measure2', 'mark1');
window.performance.measure('measure3', 'mark1', 'mark2');
});
});
}