Skip to content

Commit

Permalink
sensors: Remove cross-origin iframe test from runGenericSensorTests().
Browse files Browse the repository at this point in the history
This test is wrong, which causes it to be flaky: it just adds an iframe and
waits for it to load without properly taking care of window focus, so the
sensor in the main window continued running and we could end up receiving an
unexpected "reading" event if the iframe's "load" event took to long to be
delivered.

Remove the test altogether in favor of run_generic_sensor_iframe_tests(),
which checks for the same thing the right way (although it is also a bit
flaky...).

Bug: 731018
Change-Id: I568f032233be767a2d2a3d50bd3de8d8ce3db0ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2204024
Auto-Submit: Raphael Kubo da Costa <[email protected]>
Commit-Queue: Reilly Grant <[email protected]>
Reviewed-by: Reilly Grant <[email protected]>
Cr-Commit-Position: refs/heads/master@{#769458}
  • Loading branch information
Raphael Kubo da Costa authored and chromium-wpt-export-bot committed May 15, 2020
1 parent 4d6f847 commit 257af6a
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions generic-sensor/generic-sensor-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,41 +428,6 @@ function runGenericSensorTests(sensorName,
assert_greater_than(fastCounter, 2, "Fast sensor overtakes the slow one");
}, `${sensorName}: frequency hint works.`);

sensor_test(async (t, sensorProvider) => {
assert_true(sensorName in self);
// Create a focused editbox inside a cross-origin iframe,
// sensor notification must suspend.
const iframeSrc = 'data:text/html;charset=utf-8,<html><body>'
+ '<input type="text" autofocus></body></html>';
const iframe = document.createElement('iframe');
iframe.src = encodeURI(iframeSrc);

const sensor = new sensorType();
const sensorWatcher = new EventWatcher(t, sensor, ["reading", "error"]);
sensor.start();

const mockSensor = await sensorProvider.getCreatedSensor(sensorName);
await mockSensor.setSensorReading(readings);

await sensorWatcher.wait_for("reading");
const expected = new RingBuffer(expectedReadings).next().value;
assert_true(verificationFunction(expected, sensor));
const cachedTimestamp1 = sensor.timestamp;

const iframeWatcher = new EventWatcher(t, iframe, "load");
document.body.appendChild(iframe);
await iframeWatcher.wait_for("load");
const cachedTimestamp2 = sensor.timestamp;
assert_equals(cachedTimestamp1, cachedTimestamp2);

iframe.remove();
await sensorWatcher.wait_for("reading");
assert_greater_than(sensor.timestamp, cachedTimestamp1);

sensor.stop();
}, `${sensorName}: sensor receives suspend / resume notifications when\
cross-origin subframe is focused.`);

// Re-enable after https://github.com/w3c/sensors/issues/361 is fixed.
// test(() => {
// assert_throws_dom("NotSupportedError",
Expand Down

0 comments on commit 257af6a

Please sign in to comment.