Commit 21648f3f authored by Stephen McGruer's avatar Stephen McGruer Committed by Commit Bot

Convert some async_test(async ...) cases to promise_tests

Passing an async function to async_test will soon be disallowed in WPT,
as any asserts thrown will be turned into unhandled promise rejections
and the test will timeout. If a test needs async functions it should use
promise_test instead.

(The naming conflict is a sad historical legacy; WPT had async_test long
before EcmaScript spec'd promises!)

Bug: https://github.com/web-platform-tests/wpt/issues/21435
Change-Id: I0a31872525844a1540aea548e329929e8097663e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414923Reviewed-by: default avatarJohn Rummell <jrummell@chromium.org>
Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809464}
parent a099d2db
...@@ -18,11 +18,10 @@ ...@@ -18,11 +18,10 @@
// Navigate the iframe to URLs whose host aren't canonical. They need to be // Navigate the iframe to URLs whose host aren't canonical. They need to be
// percent encoded. Several navigation are made to ensure potential assertions // percent encoded. Several navigation are made to ensure potential assertions
// can be reached before the end of the test. See https://crbug.com/901489. // can be reached before the end of the test. See https://crbug.com/901489.
async_test(async function(t) { promise_test(async function(t) {
await navigate_iframe("http://foo,.example.test/resources/dummy.html"); await navigate_iframe("http://foo,.example.test/resources/dummy.html");
await navigate_iframe("http://bar,.example.test/resources/dummy.html"); await navigate_iframe("http://bar,.example.test/resources/dummy.html");
await navigate_iframe("http://baz,.example.test/resources/dummy.html"); await navigate_iframe("http://baz,.example.test/resources/dummy.html");
t.done();
}, "Navigate iframe to URL with non-canonicalized hostname"); }, "Navigate iframe to URL with non-canonicalized hostname");
</script> </script>
</body> </body>
...@@ -3,11 +3,10 @@ ...@@ -3,11 +3,10 @@
<script src="../resources/testharnessreport.js"></script> <script src="../resources/testharnessreport.js"></script>
<iframe id="i"></iframe> <iframe id="i"></iframe>
<script> <script>
async_test(async function(t) { promise_test(async function(t) {
let face = new FontFace("face", "url(../resources/Ahem.ttf)", {}); let face = new FontFace("face", "url(../resources/Ahem.ttf)", {});
await face.load(); await face.load();
i.contentDocument.fonts.add(face); i.contentDocument.fonts.add(face);
document.fonts.add(face); document.fonts.add(face);
t.done();
}); });
</script> </script>
...@@ -16,17 +16,18 @@ ...@@ -16,17 +16,18 @@
return iframe; return iframe;
} }
async_test(async function(test) promise_test(async function(test)
{ {
iframe = allociframe(); iframe = allociframe();
keySystemAccess = await iframe.contentWindow.navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()); keySystemAccess = await iframe.contentWindow.navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration());
keys = await keySystemAccess.createMediaKeys(); keys = await keySystemAccess.createMediaKeys();
const domException = iframe.contentWindow.DOMException;
document.body.removeChild(iframe); document.body.removeChild(iframe);
keys.getStatusForPolicy({minHdcpVersion : '1.0'}).then(function(result) { return promise_rejects_dom(test,
assert_unreached('getStatusforPolicy() should fail'); 'InvalidAccessError',
}, function(error) { domException,
test.done(); keys.getStatusForPolicy({minHdcpVersion : '1.0'}),
}); 'getStatusforPolicy() should fail');
}, 'Test context destruction.'); }, 'Test context destruction.');
</script> </script>
</body> </body>
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
); );
}; };
async_test(async function(t) { promise_test(async function(t) {
// 1. Initial navigation to about:srcdoc. // 1. Initial navigation to about:srcdoc.
assert_equals("error", await message()); assert_equals("error", await message());
...@@ -47,7 +47,5 @@ ...@@ -47,7 +47,5 @@
// (4). // (4).
iframe.srcdoc = iframe.srcdoc; iframe.srcdoc = iframe.srcdoc;
assert_equals("error", await message()); assert_equals("error", await message());
t.done();
}); });
</script> </script>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
return new Promise(resolved => window.onScriptLoaded = resolved); return new Promise(resolved => window.onScriptLoaded = resolved);
}; };
async_test(async function(t) { promise_test(async function(t) {
// 1. Check file subresource can be loaded from the initial about:srcdoc // 1. Check file subresource can be loaded from the initial about:srcdoc
// document. // document.
await scriptLoaded(); await scriptLoaded();
...@@ -30,6 +30,5 @@ ...@@ -30,6 +30,5 @@
// 2. Check file subresource can be loaded again after a new navigation to // 2. Check file subresource can be loaded again after a new navigation to
// about:srcdoc. // about:srcdoc.
await scriptLoaded(); await scriptLoaded();
t.done();
}); });
</script> </script>
...@@ -11,11 +11,10 @@ ...@@ -11,11 +11,10 @@
<script> <script>
'use strict'; 'use strict';
async_test(async t => { promise_test(async t => {
const adapter = await navigator.gpu.requestAdapter(); const adapter = await navigator.gpu.requestAdapter();
assert_true(adapter !== null); assert_true(adapter !== null);
const device = await adapter.requestDevice(); const device = await adapter.requestDevice();
assert_true(device !== null); assert_true(device !== null);
t.done();
}); });
</script> </script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment