1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/webxr_util.js"></script>
<script src="../resources/webxr_test_constants.js"></script>
<script src="../resources/webxr_test_constants_fake_world.js"></script>
<script src="../resources/webxr_test_asserts.js"></script>
<style type="text/css">
div {
padding: 10px;
min-width: 10px;
min-height: 10px;
}
iframe {
border: 0;
width: 20px;
height: 20px;
}
</style>
<div id="div_overlay">
<div id="inner_b">
</div>
<!-- This SVG iframe is treated as cross-origin content. -->
<iframe id="iframe" src='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><rect height="20" width="20" fill="red" fill-opacity="0.3"/></svg>'>
</iframe>
<canvas>
</canvas>
</div>
<script>
const fakeDeviceInitParams = {
supportedModes: ["immersive-ar"],
views: VALID_VIEWS,
viewerOrigin: IDENTITY_TRANSFORM,
supportedFeatures: ALL_FEATURES,
world: createFakeWorld(5.0, 2.0, 5.0), // see webxr_test_constants_fake_world.js for details
};
const hitTestOptionsInit = {
profile: "generic-touchscreen",
offsetRay: new XRRay(),
};
const SCREEN_POINTER_TRANSFORM = {
position: [0, 0, 0], // middle of the screen
orientation: [0, 0, 0, 1] // forward-facing
};
const screen_controller_init = {
handedness: "none",
targetRayMode: "screen",
pointerOrigin: SCREEN_POINTER_TRANSFORM, // aka mojo_from_pointer
profiles: ["generic-touchscreen",]
};
const testCrossOriginContent = function(overlayElement, session, fakeDeviceController, t) {
const iframe = document.getElementById('iframe');
const inner_b = document.getElementById('inner_b');
let debug = xr_debug.bind(this, 'testCrossOriginContent');
const input_source =
fakeDeviceController.simulateInputSourceConnection(screen_controller_init);
debug('start');
return session.requestReferenceSpace('viewer').then(function(viewerSpace) {
debug('got viewerSpace');
return session.requestHitTestSourceForTransientInput(hitTestOptionsInit)
.then((hitTestSource) => {
debug('got hitTestSource');
return new Promise((resolve) => {
// Press the primary input button and then release it a short time later.
session.requestAnimationFrame((time, xrFrame) => {
debug('got rAF 1');
input_source.setOverlayPointerPosition(iframe.offsetLeft + 1,
iframe.offsetTop + 1);
input_source.startSelection();
session.requestAnimationFrame((time, xrFrame) => {
input_source.endSelection();
// There should be no results for transient input for cross origin content:
const results = xrFrame.getHitTestResultsForTransientInput(hitTestSource);
t.step(() => {
assert_equals(results.length, 0, "Hit test results should be suppressed for cross-origin content");
});
session.requestAnimationFrame((time, xrFrame) => {
debug('got rAF 2');
// Need to process one more frame to allow select to propagate
session.requestAnimationFrame((time, xrFrame) => {
debug('got rAF 3');
input_source.setOverlayPointerPosition(inner_b.offsetLeft + 1,
inner_b.offsetTop + 1);
input_source.startSelection();
session.requestAnimationFrame((time, xrFrame) => {
debug('got rAF 4');
input_source.endSelection();
const results = xrFrame.getHitTestResultsForTransientInput(hitTestSource);
t.step(() => {
// TODO(bialpio): this assertion is currently failing, FIXME
assert_equals(results.length, 1, "Hit test results should be available for same-origin content");
});
debug('resolving');
resolve();
});
});
});
});
});
});
});
});
};
xr_session_promise_test(
"Ensures DOM Overlay interactions on cross origin iframe do not cause hit test results to come up",
testCrossOriginContent.bind(this, document.getElementById('div_overlay')),
fakeDeviceInitParams, 'immersive-ar', {
requiredFeatures: ['dom-overlay', 'hit-test'],
domOverlay: { root: document.getElementById('div_overlay') }
});
</script>
|