-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebXR should not work from an iFrame unless it is allowed to use the …
…xr-spatial-tracking permissions policy https://bugs.webkit.org/show_bug.cgi?id=271363 rdar://122963817 Reviewed by Mike Wyrzykowski. Follow the latest WebXR spec and check whether 'xr-spatial-tracking' is enabled for the requesting document's origin in WebGLRenderingContextBase::makeXRCompatible and WebXRSystem::resolveRequestedFeatures. Added layout tests to verify 'xr-spatial-tracking' permissions policy is checked properly for xr.isSessionSupported, xr.requestSession, and WebGLRenderingContextBase::makeXRCompatible. Set up symbolic links to the webxr related scripts from http/wpt/webxr folder so the pages embedded in the iframes can reference them. * LayoutTests/http/tests/webxr/resources/resources/test-only-api.js: Added. * LayoutTests/http/tests/webxr/resources/resources/webxr_test_constants_single_view.js: Added. * LayoutTests/http/tests/webxr/resources/resources/webxr_util.js: Added. * LayoutTests/http/tests/webxr/resources/webxr-issessionsupported-test.html: Added. * LayoutTests/http/tests/webxr/resources/webxr-makexrcompatible-test.html: Added. * LayoutTests/http/tests/webxr/resources/webxr-requestsession-test.html: Added. * LayoutTests/http/tests/webxr/webxr-third-party-iframe-issessionsupported-allowed-by-feature-policy-expected.txt: Added. * LayoutTests/http/tests/webxr/webxr-third-party-iframe-issessionsupported-allowed-by-feature-policy.html: Added. * LayoutTests/http/tests/webxr/webxr-third-party-iframe-issessionsupported-denied-by-insufficient-feature-policy-expected.txt: Added. * LayoutTests/http/tests/webxr/webxr-third-party-iframe-issessionsupported-denied-by-insufficient-feature-policy.html: Added. * LayoutTests/http/tests/webxr/webxr-third-party-iframe-makexrcompatible-allowed-by-feature-policy-expected.txt: Added. * LayoutTests/http/tests/webxr/webxr-third-party-iframe-makexrcompatible-allowed-by-feature-policy.html: Added. * LayoutTests/http/tests/webxr/webxr-third-party-iframe-makexrcompatible-denied-by-insufficient-feature-policy-expected.txt: Added. * LayoutTests/http/tests/webxr/webxr-third-party-iframe-makexrcompatible-denied-by-insufficient-feature-policy.html: Added. * LayoutTests/http/tests/webxr/webxr-third-party-iframe-requestsession-allowed-by-feature-policy-expected.txt: Added. * LayoutTests/http/tests/webxr/webxr-third-party-iframe-requestsession-allowed-by-feature-policy.html: Added. * LayoutTests/http/tests/webxr/webxr-third-party-iframe-requestsession-denied-by-insufficient-feature-policy-expected.txt: Added. * LayoutTests/http/tests/webxr/webxr-third-party-iframe-requestsession-denied-by-insufficient-feature-policy.html: Added. * LayoutTests/platform/gtk/TestExpectations: * LayoutTests/platform/ios/TestExpectations: * LayoutTests/platform/mac-gpup/TestExpectations: * LayoutTests/platform/mac/TestExpectations: Skip http/tests/webxr tests in the same places where we've skipped other webxr layout tests. * LayoutTests/platform/wpe/TestExpectations: Filed a new bug on a crash found when calling WebXRSession destructor. * LayoutTests/platform/wincairo/TestExpectations: Skip http/tests/webxr tests in the same places where we've skipped other webxr layout tests. * Source/WebCore/Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::isFeaturePermitted const): (WebCore::WebXRSystem::resolveRequestedFeatures const): * Source/WebCore/Modules/webxr/WebXRSystem.h: * Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp: (WebCore::WebGLRenderingContextBase::makeXRCompatible): Canonical link: https://commits.webkit.org/277301@main
- Loading branch information
Showing
27 changed files
with
294 additions
and
3 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
LayoutTests/http/tests/webxr/resources/resources/test-only-api.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../wpt/webxr/resources/test-only-api.js |
1 change: 1 addition & 0 deletions
1
LayoutTests/http/tests/webxr/resources/resources/webxr_test_constants_single_view.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../wpt/webxr/resources/webxr_test_constants_single_view.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../wpt/webxr/resources/webxr_util.js |
23 changes: 23 additions & 0 deletions
23
LayoutTests/http/tests/webxr/resources/webxr-issessionsupported-test.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<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_single_view.js"></script> | ||
<script> | ||
xr_promise_test( | ||
"Tests isSessionSupported with immersive device connected", | ||
async (t) => { | ||
await navigator.xr.test.simulateDeviceConnection(TRACKED_IMMERSIVE_DEVICE); | ||
try { | ||
const supported = await navigator.xr.isSessionSupported('immersive-vr'); | ||
top.postMessage({'isSessionSupported': supported}, '*'); | ||
} catch (e) { | ||
top.postMessage({'isSessionSupported': e.name}, '*'); | ||
} | ||
} | ||
); | ||
</script> | ||
</body> | ||
</html> |
23 changes: 23 additions & 0 deletions
23
LayoutTests/http/tests/webxr/resources/webxr-makexrcompatible-test.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<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_single_view.js"></script> | ||
<script> | ||
async function testMakeXRCompatible(t, gl) { | ||
await navigator.xr.test.simulateDeviceConnection(TRACKED_IMMERSIVE_DEVICE); | ||
await gl.makeXRCompatible(); | ||
top.postMessage({'makeXRCompatible': gl.getContextAttributes().xrCompatible}, '*'); | ||
} | ||
|
||
xr_promise_test( | ||
"Tests makeXRCompatible with immersive device connected", | ||
testMakeXRCompatible, | ||
null, | ||
'webgl' | ||
); | ||
</script> | ||
</body> | ||
</html> |
26 changes: 26 additions & 0 deletions
26
LayoutTests/http/tests/webxr/resources/webxr-requestsession-test.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<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_single_view.js"></script> | ||
<script> | ||
xr_promise_test( | ||
"Tests requestSession when connected to immersive device", | ||
async (t) => { | ||
await navigator.xr.test.simulateDeviceConnection(TRACKED_IMMERSIVE_DEVICE); | ||
navigator.xr.test.simulateUserActivation(async () => { | ||
window.focus(); | ||
try { | ||
const session = await navigator.xr.requestSession('immersive-vr'); | ||
top.postMessage({'requestSession': session != null}, '*'); | ||
} catch (e) { | ||
top.postMessage({'requestSession': e.name}, '*'); | ||
} | ||
}); | ||
} | ||
); | ||
</script> | ||
</body> | ||
</html> |
10 changes: 10 additions & 0 deletions
10
.../webxr/webxr-third-party-iframe-issessionsupported-allowed-by-feature-policy-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Tests that third-party iframes will be allowed webxr session support with xr-spatial-tracking feature policy. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS e.data.isSessionSupported is true | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
19 changes: 19 additions & 0 deletions
19
...tp/tests/webxr/webxr-third-party-iframe-issessionsupported-allowed-by-feature-policy.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
<script> | ||
description("Tests that third-party iframes will be allowed webxr session support with xr-spatial-tracking feature policy."); | ||
jsTestIsAsync = true; | ||
|
||
onmessage = (_e) => { | ||
e = _e; | ||
if (e.data.isSessionSupported != undefined) { | ||
shouldBeTrue("e.data.isSessionSupported"); | ||
finishJSTest(); | ||
} | ||
}; | ||
</script> | ||
<iframe src="http://localhost:8000/webxr/resources/webxr-issessionsupported-test.html" allow="xr-spatial-tracking"></iframe> | ||
</body> | ||
</html> |
11 changes: 11 additions & 0 deletions
11
...-third-party-iframe-issessionsupported-denied-by-insufficient-feature-policy-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CONSOLE MESSAGE: Feature policy 'XRSpatialTracking' check failed for element with origin 'http://localhost:8000' and allow attribute ''. | ||
Tests that third-party iframes will be denied webxr session support without xr-spatial-tracking feature policy. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS e.data.isSessionSupported is "SecurityError" | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
19 changes: 19 additions & 0 deletions
19
...xr/webxr-third-party-iframe-issessionsupported-denied-by-insufficient-feature-policy.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
<script> | ||
description("Tests that third-party iframes will be denied webxr session support without xr-spatial-tracking feature policy."); | ||
jsTestIsAsync = true; | ||
|
||
onmessage = (_e) => { | ||
e = _e; | ||
if (e.data.isSessionSupported != undefined) { | ||
shouldBeEqualToString("e.data.isSessionSupported", "SecurityError"); | ||
finishJSTest(); | ||
} | ||
}; | ||
</script> | ||
<iframe src="http://localhost:8000/webxr/resources/webxr-issessionsupported-test.html"></iframe> | ||
</body> | ||
</html> |
10 changes: 10 additions & 0 deletions
10
...ts/webxr/webxr-third-party-iframe-makexrcompatible-allowed-by-feature-policy-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Tests that third-party iframes will be allowed to call makeXRCompatible() with xr-spatial-tracking feature policy. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS e.data.makeXRCompatible is true | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
19 changes: 19 additions & 0 deletions
19
...http/tests/webxr/webxr-third-party-iframe-makexrcompatible-allowed-by-feature-policy.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
<script> | ||
description("Tests that third-party iframes will be allowed to call makeXRCompatible() with xr-spatial-tracking feature policy."); | ||
jsTestIsAsync = true; | ||
|
||
onmessage = (_e) => { | ||
e = _e; | ||
if (e.data.makeXRCompatible != undefined) { | ||
shouldBeTrue("e.data.makeXRCompatible"); | ||
finishJSTest(); | ||
} | ||
}; | ||
</script> | ||
<iframe src="http://localhost:8000/webxr/resources/webxr-makexrcompatible-test.html" allow="xr-spatial-tracking"></iframe> | ||
</body> | ||
</html> |
11 changes: 11 additions & 0 deletions
11
...xr-third-party-iframe-makexrcompatible-denied-by-insufficient-feature-policy-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CONSOLE MESSAGE: Feature policy 'XRSpatialTracking' check failed for element with origin 'http://localhost:8000' and allow attribute ''. | ||
Tests that third-party iframes will be denied from calling makeXRCompatible() without xr-spatial-tracking feature policy. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS e.data.makeXRCompatible is false | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
19 changes: 19 additions & 0 deletions
19
...ebxr/webxr-third-party-iframe-makexrcompatible-denied-by-insufficient-feature-policy.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
<script> | ||
description("Tests that third-party iframes will be denied from calling makeXRCompatible() without xr-spatial-tracking feature policy."); | ||
jsTestIsAsync = true; | ||
|
||
onmessage = (_e) => { | ||
e = _e; | ||
if (e.data.makeXRCompatible != undefined) { | ||
shouldBeFalse("e.data.makeXRCompatible"); | ||
finishJSTest(); | ||
} | ||
}; | ||
</script> | ||
<iframe src="http://localhost:8000/webxr/resources/webxr-makexrcompatible-test.html"></iframe> | ||
</body> | ||
</html> |
10 changes: 10 additions & 0 deletions
10
...ests/webxr/webxr-third-party-iframe-requestsession-allowed-by-feature-policy-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Tests that third-party iframes will be allowed to request webxr session with xr-spatial-tracking feature policy. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS e.data.requestSession is true | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
19 changes: 19 additions & 0 deletions
19
...s/http/tests/webxr/webxr-third-party-iframe-requestsession-allowed-by-feature-policy.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
<script> | ||
description("Tests that third-party iframes will be allowed to request webxr session with xr-spatial-tracking feature policy."); | ||
jsTestIsAsync = true; | ||
|
||
onmessage = (_e) => { | ||
e = _e; | ||
if (e.data.requestSession != undefined) { | ||
shouldBeTrue("e.data.requestSession"); | ||
finishJSTest(); | ||
} | ||
}; | ||
</script> | ||
<iframe src="http://localhost:8000/webxr/resources/webxr-requestsession-test.html" allow="xr-spatial-tracking"></iframe> | ||
</body> | ||
</html> |
11 changes: 11 additions & 0 deletions
11
...ebxr-third-party-iframe-requestsession-denied-by-insufficient-feature-policy-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CONSOLE MESSAGE: Feature policy 'XRSpatialTracking' check failed for element with origin 'http://localhost:8000' and allow attribute ''. | ||
Tests that third-party iframes will be denied from requesting webxr session without xr-spatial-tracking feature policy. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS e.data.requestSession is "NotSupportedError" | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
19 changes: 19 additions & 0 deletions
19
.../webxr/webxr-third-party-iframe-requestsession-denied-by-insufficient-feature-policy.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
<script> | ||
description("Tests that third-party iframes will be denied from requesting webxr session without xr-spatial-tracking feature policy."); | ||
jsTestIsAsync = true; | ||
|
||
onmessage = (_e) => { | ||
e = _e; | ||
if (e.data.requestSession != undefined) { | ||
shouldBeEqualToString("e.data.requestSession", "NotSupportedError"); | ||
finishJSTest(); | ||
} | ||
}; | ||
</script> | ||
<iframe src="http://localhost:8000/webxr/resources/webxr-requestSession-test.html"></iframe> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters