Skip to content

Commit

Permalink
[generic-sensor] Avoid unhandled promise rejection (#16414)
Browse files Browse the repository at this point in the history
By testing for a global binding via an unqualified IdentifierReference,
the Generic Sensor utility file produces a rejected promise which is not
handled. If testharness.js has not yet determined that testing is
complete, this unhandled rejection will cause a harness-level error.
Such errors will occur based on relative timing of asynchronous
operations, and this has been observed to be unstable in Apple Safari as
hosted on Azure Pipelines.

Update the feature detection logic to avoid generating an unhandled
rejection by instead referencing a property of the global object. Update
the subsquent assertion to provide a more clear explanation of the
failure which occurs in non-supporting browsers.
  • Loading branch information
jugglinmike authored and Marcos Cáceres committed Jul 23, 2019
1 parent 283ec9a commit 8791934
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions generic-sensor/generic-sensor-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//
// --enable-blink-features=MojoJS,MojoJSTest
let loadChromiumResources = Promise.resolve().then(() => {
if (!MojoInterfaceInterceptor) {
if (!window.MojoInterfaceInterceptor) {
// Do nothing on non-Chromium-based browsers or when the Mojo bindings are
// not present in the global namespace.
return;
Expand Down Expand Up @@ -37,7 +37,10 @@ async function initialize_generic_sensor_tests() {
if (typeof GenericSensorTest === 'undefined') {
await loadChromiumResources;
}
assert_true(typeof GenericSensorTest !== 'undefined');
assert_true(
typeof GenericSensorTest !== 'undefined',
'Mojo testing interface is not available.'
);
let sensorTest = new GenericSensorTest();
await sensorTest.initialize();
return sensorTest;
Expand Down

0 comments on commit 8791934

Please sign in to comment.