Bug 1837184 [wpt PR 40415] - sensors: Reset sensor state on context destruction., a=testonly

Automatic update from web-platform-tests
sensors: Reset sensor state on context destruction.

Sensor::ContextDestroyed() did not reset |state_|, which could lead to a
crash in SensorProxyImpl::RemoveActiveFrequency() if Sensor::stop()
ended up being invoked later (e.g. via a reference to an object created
in an iframe).

Fixed: 1453186
Change-Id: I14d58f012af300631f43494b2d8a75fc0ca52562
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4595840
Auto-Submit: Raphael Kubo Da Costa <raphael.kubo.da.costa@intel.com>
Commit-Queue: Raphael Kubo Da Costa <raphael.kubo.da.costa@intel.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1154979}

--

wpt-commits: 99f37e54b8b701acb046904a11a987fe6b0a84bd
wpt-pr: 40415
This commit is contained in:
Raphael Kubo da Costa 2023-06-19 19:55:57 +00:00 коммит произвёл moz-wptsync-bot
Родитель 090bd1a5c5
Коммит d12b795885
1 изменённых файлов: 10 добавлений и 5 удалений

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

@ -135,23 +135,28 @@ function run_generic_sensor_iframe_tests(sensorName) {
iframe.allow = featurePolicies.join(';') + ';';
iframe.src = 'https://{{host}}:{{ports[https][0]}}/generic-sensor/resources/iframe_sensor_handler.html';
// Create sensor in the iframe (we do not care whether this is a
// cross-origin nested context in this test).
// Create sensor in the iframe.
const iframeLoadWatcher = new EventWatcher(t, iframe, 'load');
document.body.appendChild(iframe);
await iframeLoadWatcher.wait_for('load');
// This is required for the JS Mojo backend to be initialized in the
// iframe.
await send_message_to_iframe(iframe, {command: 'create_sensor',
type: sensorName});
iframe.contentWindow.focus();
await send_message_to_iframe(iframe, {command: 'start_sensor'});
const iframeSensor = new iframe.contentWindow[sensorName]();
t.add_cleanup(() => {
iframeSensor.stop();
});
const sensorWatcher = new EventWatcher(t, iframeSensor, ['activate']);
iframeSensor.start();
await sensorWatcher.wait_for('activate');
// Remove iframe from main document and change focus. When focus changes,
// we need to determine whether a sensor must have its execution suspended
// or resumed (section 4.2.3, "Focused Area" of the Generic Sensor API
// spec). In Blink, this involves querying a frame, which might no longer
// exist at the time of the check.
// Note that we cannot send the "reset_sensor_backend" command because the
// iframe is discarded with the removeChild call.
iframe.parentNode.removeChild(iframe);
window.focus();
}, `${sensorName}: losing a document's frame with an active sensor does not crash`);