mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #24133 - paulrouget:userAction, r=jdm
Do not allow XR session on non user-activated events This sets the thread in "user interaction mode" when the dispatched event is trusted. I also tried an approach where we would not rely on the dispatched event but just set "user interaction mode" when we get a compositor event (which, we can assume, are only user generated). That worked as well. Fixes #23787. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/24133) <!-- Reviewable:end -->
This commit is contained in:
commit
293ccd07e8
9 changed files with 54 additions and 15 deletions
|
@ -23,6 +23,7 @@ use crate::dom::vrdisplay::VRDisplay;
|
|||
use crate::dom::vrdisplayevent::VRDisplayEvent;
|
||||
use crate::dom::xrsession::XRSession;
|
||||
use crate::dom::xrtest::XRTest;
|
||||
use crate::script_thread::ScriptThread;
|
||||
use crate::task_source::TaskSource;
|
||||
use dom_struct::dom_struct;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
|
@ -157,6 +158,11 @@ impl XRMethods for XR {
|
|||
) -> Rc<Promise> {
|
||||
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
||||
|
||||
if !ScriptThread::is_user_interacting() {
|
||||
promise.reject_error(Error::Security);
|
||||
return promise;
|
||||
}
|
||||
|
||||
if self.pending_or_active_session() {
|
||||
promise.reject_error(Error::InvalidState);
|
||||
return promise;
|
||||
|
|
|
@ -18,6 +18,7 @@ use crate::dom::bindings::root::{Dom, DomRoot};
|
|||
use crate::dom::fakexrdevice::{get_origin, get_views, FakeXRDevice};
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::promise::Promise;
|
||||
use crate::script_thread::ScriptThread;
|
||||
use crate::task_source::TaskSource;
|
||||
use dom_struct::dom_struct;
|
||||
use euclid::RigidTransform3D;
|
||||
|
@ -159,8 +160,9 @@ impl XRTestMethods for XRTest {
|
|||
|
||||
/// https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md
|
||||
fn SimulateUserActivation(&self, f: Rc<Function>) {
|
||||
// XXXManishearth actually check for activation in XRSession
|
||||
ScriptThread::set_user_interacting(true);
|
||||
let _ = f.Call__(vec![], ExceptionHandling::Rethrow);
|
||||
ScriptThread::set_user_interacting(false);
|
||||
}
|
||||
|
||||
/// https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue