Bug 1698854 [wpt PR 28103] - [ResourceTiming]: Prefer arrow-functions to function declarations, a=testonly

Automatic update from web-platform-tests
[ResourceTiming]: Prefer arrow-functions to function declarations

To help with readability, we want to have a consistent style for
function declaration within ResourceTiming's WPTs.

This change amends the style guide to recommend which function
declaration syntax we prefer. It also updates the tests we've already
'modernized' to conform to the updated style guide.

Bug: 1171767
Change-Id: I5910d4de28ad911800d2bdd416bf4fbea7062ce1
GithubIssue: https://github.com/w3c/resource-timing/issues/254
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2764663
Reviewed-by: Yoav Weiss <yoavweiss@chromium.org>
Commit-Queue: Tom McKee <tommckee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#863346}

--

wpt-commits: d704ab5211988322def53529c5d1c3ea5aeb7dc7
wpt-pr: 28103
This commit is contained in:
Tom McKee 2021-03-17 13:35:44 +00:00 коммит произвёл moz-wptsync-bot
Родитель f7a924a5be
Коммит d1c770d59e
3 изменённых файлов: 22 добавлений и 10 удалений

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

@ -26,6 +26,12 @@ with recurring patterns.
* Consistent use of anonymous functions
* prefer
```
const func1 = param1 => {
body();
}
const func2 = (param1, param2) => {
body();
}
fn(param => {
body();
});
@ -34,6 +40,12 @@ with recurring patterns.
over
```
function func1(param1) {
body();
}
function func2(param1, param2) {
body();
}
fn(function(param) {
body();
});

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

@ -19,7 +19,7 @@
<script id="script_502"></script>
<script>
function listenForPerformanceEntries(num_expected) {
const listenForPerformanceEntries = num_expected => {
return new Promise(resolve => {
let results = [];
new PerformanceObserver(entryList => {

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

@ -10,7 +10,7 @@
// Returns a promise that settles once the given path has been fetched as an
// image resource.
function load_image(path) {
const load_image = path => {
return new Promise(resolve => {
const img = new Image();
img.onload = img.onerror = resolve;
@ -20,7 +20,7 @@ function load_image(path) {
// Returns a promise that settles once the given path has been fetched as a
// font resource.
function load_font(path) {
const load_font = path => {
document.getElementById('forFonts').innerHTML = `
<style>
@font-face {
@ -33,7 +33,7 @@ function load_font(path) {
return document.fonts.ready;
}
function assert_ordered(entry, attributes) {
const assert_ordered = (entry, attributes) => {
let before = attributes[0];
attributes.slice(1).forEach(after => {
assert_greater_than_equal(entry[after], entry[before],
@ -42,27 +42,27 @@ function assert_ordered(entry, attributes) {
});
}
function assert_zeroed(entry, attributes) {
const assert_zeroed = (entry, attributes) => {
attributes.forEach(attribute => {
assert_equals(entry[attribute], 0, `${attribute} should be 0`);
});
}
function assert_not_negative(entry, attributes) {
const assert_not_negative = (entry, attributes) => {
attributes.forEach(attribute => {
assert_greater_than_equal(entry[attribute], 0,
`${attribute} should be greater than or equal to 0`);
});
}
function assert_positive(entry, attributes) {
const assert_positive = (entry, attributes) => {
attributes.forEach(attribute => {
assert_greater_than(entry[attribute], 0,
`${attribute} should be greater than 0`);
});
}
function assert_http_resource(entry) {
const assert_http_resource = entry => {
assert_ordered(entry, [
"fetchStart",
"domainLookupStart",
@ -93,7 +93,7 @@ function assert_http_resource(entry) {
]);
}
function assert_same_origin_redirected_resource(entry) {
const assert_same_origin_redirected_resource = entry => {
assert_positive(entry, [
"redirectStart",
]);
@ -113,7 +113,7 @@ function assert_same_origin_redirected_resource(entry) {
// Given a resource-loader and a PerformanceResourceTiming validator, loads a
// resource and validates the resulting entry.
function attribute_test(load_resource, validate, test_label) {
const attribute_test = (load_resource, validate, test_label) => {
promise_test(
async () => {
// Clear out everything that isn't the one ResourceTiming entry under test.