Skip to content

Commit

Permalink
Wrap event handlers in Client Hints tests in t.step_func (web-platf…
Browse files Browse the repository at this point in the history
…orm-tests#17164)

Without this, any failed assert will cause a harness error instead of
failing the test.

Note that some problematic use like
`win.addEventListener('load', acceptChLifetimeLoaded, false)` remains,
but fixing these would require introducing new tests.
  • Loading branch information
foolip authored Jun 4, 2019
1 parent 95fd9ed commit 8805e11
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions client-hints/accept_ch.tentative.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
}, "Precondition: Test that the browser does not have client hints preferences cached");

async_test(t => {
window.addEventListener('message', function(e) {
window.addEventListener('message', t.step_func(function(e) {
if(!e.source.location.pathname.includes("do_not_expect_client_hints_headers.html")) {
return;
}
if(typeof e.data != "string")
return;
assert_equals(e.data, "PASS");
t.done();
})
}));
}, "Loading of resources/do_not_expect_client_hints_headers.html did not finish.");

function acceptChLoaded() {
Expand Down
4 changes: 2 additions & 2 deletions client-hints/accept_ch_lifetime.tentative.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
}, "Precondition: Test that the browser does not have client hints preferences cached");

async_test(t => {
window.addEventListener('message', function(e) {
window.addEventListener('message', t.step_func(function(e) {
if(!e.source.location.pathname.includes("expect_client_hints_headers.html")) {
return;
}
if(typeof e.data != "string")
return;
assert_equals(e.data, "PASS");
t.done();
})
}));
}, "Loading of resources/expect_client_hints_headers.html did not finish.");


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
}, "Precondition: Test that the browser does not have client hints preferences cached");

async_test(t => {
window.addEventListener('message', function(e) {
window.addEventListener('message', t.step_func(function(e) {
if(!e.source.location.pathname.includes("do_not_expect_client_hints_headers.html")) {
return;
}
if(typeof e.data != "string")
return;
assert_equals(e.data, "PASS");
t.done();
})
}));
}, "Loading of resources/do_not_expect_client_hints_headers.html did not finish.");

function acceptChLifetimeLoaded() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@
}, "Test receiving Accept-CH-Lifetime header");

async_test(t => {
window.addEventListener('message', function(e) {
window.addEventListener('message', t.step_func(function(e) {
if(!e.source.location.pathname.includes("do_not_expect_client_hints_headers.html")) {
return;
}
if(typeof e.data != "string")
return;
assert_equals(e.data, "PASS");
t.done();
})
}));
}, "Loading of resources/do_not_expect_client_hints_headers.html did not finish.");

</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
}, "Precondition: Test that the browser does not have client hints preferences cached");

async_test(t => {
window.addEventListener('message', function(e) {
window.addEventListener('message', t.step_func(function(e) {
if(!e.source.location.pathname.includes("expect_client_hints_headers.html")) {
return;
}
if(typeof e.data != "string")
return;
assert_equals(e.data, "PASS");
t.done();
})
}));
}, "Loading of resources/expect_client_hints_headers.html did not finish.");

function acceptChLifetimeLoaded() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
}, "Precondition: Test that the browser does not have client hints preferences cached");

async_test(t => {
window.addEventListener('message', function(e) {
window.addEventListener('message', t.step_func(function(e) {
if(!e.source.location.pathname.includes("do_not_expect_client_hints_headers.html")) {
return;
}
if(typeof e.data != "string")
return;
assert_equals(e.data, "PASS");
t.done();
})
}));
}, "Loading of resources/do_not_expect_client_hints_headers.html did not finish.");

function acceptChLifetimeLoaded() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@
}, "Test receiving Accept-CH-Lifetime header");

async_test(t => {
window.addEventListener('message', function(e) {
window.addEventListener('message', t.step_func(function(e) {
if(!e.source.location.pathname.includes("do_not_expect_client_hints_headers.html")) {
return;
}
if(typeof e.data != "string")
return;
assert_equals(e.data, "PASS");
t.done();
})
}));
}, "Loading of resources/do_not_expect_client_hints_headers.html did not finish.");


Expand Down

0 comments on commit 8805e11

Please sign in to comment.