How to use setupWebKitWebXRTestAPI method in wpt

Best JavaScript code snippet using wpt

webxr_util.js

Source:webxr_util.js Github

copy

Full Screen

...31 // Chrome setup32 await loadChromiumResources();33 } else if (isWebKitBased) {34 // WebKit setup35 await setupWebKitWebXRTestAPI();36 }37 }38 // Either the test api needs to be polyfilled and it's not set up above, or39 // something happened to one of the known polyfills and it failed to be40 // setup properly. Either way, the fact that xr_promise_test is being used41 // means that the tests expect navigator.xr.test to be set. By rejecting now42 // we can hopefully provide a clearer indication of what went wrong.43 assert_implements(navigator.xr.test, 'missing navigator.xr.test, even after attempted load');44 let gl = null;45 let canvas = null;46 if (glContextType) {47 canvas = document.createElement('canvas');48 document.body.appendChild(canvas);49 gl = canvas.getContext(glContextType, glContextProperties);50 }51 // Ensure that any devices are disconnected when done. If this were done in52 // a .then() for the success case, a test that expected failure would53 // already be marked done at the time that runs and the shutdown would54 // interfere with the next test.55 t.add_cleanup(async () => {56 // Ensure system state is cleaned up.57 xr_debug(name, 'cleanup');58 await navigator.xr.test.disconnectAllDevices();59 });60 xr_debug(name, 'main');61 return func(t, gl);62 }, name, properties);63}64// A utility function for waiting one animation frame before running the callback65//66// This is only needed after calling FakeXRDevice methods outside of an animation frame67//68// This is so that we can paper over the potential race allowed by the "next animation frame"69// concept https://immersive-web.github.io/webxr-test-api/#xrsession-next-animation-frame70function requestSkipAnimationFrame(session, callback) {71 session.requestAnimationFrame(() => {72 session.requestAnimationFrame(callback);73 });74}75// A test function which runs through the common steps of requesting a session.76// Calls the passed in test function with the session, the controller for the77// device, and the test object.78function xr_session_promise_test(79 name, func, fakeDeviceInit, sessionMode, sessionInit, properties, glcontextPropertiesParam, gllayerPropertiesParam) {80 const glcontextProperties = (glcontextPropertiesParam) ? glcontextPropertiesParam : {};81 const gllayerProperties = (gllayerPropertiesParam) ? gllayerPropertiesParam : {};82 function runTest(t, glContext) {83 let testSession;84 let testDeviceController;85 let sessionObjects = {gl: glContext};86 // Ensure that any pending sessions are ended when done. This needs to87 // use a cleanup function to ensure proper sequencing. If this were88 // done in a .then() for the success case, a test that expected89 // failure would already be marked done at the time that runs, and the90 // shutdown would interfere with the next test which may have started.91 t.add_cleanup(async () => {92 // If a session was created, end it.93 if (testSession) {94 await testSession.end().catch(() => {});95 }96 });97 return navigator.xr.test.simulateDeviceConnection(fakeDeviceInit)98 .then((controller) => {99 testDeviceController = controller;100 return sessionObjects.gl.makeXRCompatible();101 })102 .then(() => new Promise((resolve, reject) => {103 // Perform the session request in a user gesture.104 xr_debug(name, 'simulateUserActivation');105 navigator.xr.test.simulateUserActivation(() => {106 xr_debug(name, 'document.hasFocus()=' + document.hasFocus());107 navigator.xr.requestSession(sessionMode, sessionInit || {})108 .then((session) => {109 xr_debug(name, 'session start');110 testSession = session;111 session.mode = sessionMode;112 let glLayer = new XRWebGLLayer(session, sessionObjects.gl, gllayerProperties);113 glLayer.context = sessionObjects.gl;114 // Session must have a baseLayer or frame requests115 // will be ignored.116 session.updateRenderState({117 baseLayer: glLayer118 });119 sessionObjects.glLayer = glLayer;120 xr_debug(name, 'session.visibilityState=' + session.visibilityState);121 resolve(func(session, testDeviceController, t, sessionObjects));122 })123 .catch((err) => {124 xr_debug(name, 'error: ' + err);125 reject(126 'Session with params ' +127 JSON.stringify(sessionMode) +128 ' was rejected on device ' +129 JSON.stringify(fakeDeviceInit) +130 ' with error: ' + err);131 });132 });133 }));134 }135 xr_promise_test(136 name + ' - webgl',137 runTest,138 properties,139 'webgl',140 {alpha: false, antialias: false, ...glcontextProperties}141 );142 xr_promise_test(143 name + ' - webgl2',144 runTest,145 properties,146 'webgl2',147 {alpha: false, antialias: false, ...glcontextProperties});148}149// This function wraps the provided function in a150// simulateUserActivation() call, and resolves the promise with the151// result of func(), or an error if one is thrown152function promise_simulate_user_activation(func) {153 return new Promise((resolve, reject) => {154 navigator.xr.test.simulateUserActivation(() => {155 try { let a = func(); resolve(a); } catch(e) { reject(e); }156 });157 });158}159// This functions calls a callback with each API object as specified160// by https://immersive-web.github.io/webxr/spec/latest/, allowing161// checks to be made on all ojects.162// Arguements:163// callback: A callback function with two arguements, the first164// being the API object, the second being the name of165// that API object.166function forEachWebxrObject(callback) {167 callback(window.navigator.xr, 'navigator.xr');168 callback(window.XRSession, 'XRSession');169 callback(window.XRSessionCreationOptions, 'XRSessionCreationOptions');170 callback(window.XRFrameRequestCallback, 'XRFrameRequestCallback');171 callback(window.XRPresentationContext, 'XRPresentationContext');172 callback(window.XRFrame, 'XRFrame');173 callback(window.XRLayer, 'XRLayer');174 callback(window.XRView, 'XRView');175 callback(window.XRViewport, 'XRViewport');176 callback(window.XRViewerPose, 'XRViewerPose');177 callback(window.XRWebGLLayer, 'XRWebGLLayer');178 callback(window.XRWebGLLayerInit, 'XRWebGLLayerInit');179 callback(window.XRCoordinateSystem, 'XRCoordinateSystem');180 callback(window.XRFrameOfReference, 'XRFrameOfReference');181 callback(window.XRStageBounds, 'XRStageBounds');182 callback(window.XRSessionEvent, 'XRSessionEvent');183 callback(window.XRCoordinateSystemEvent, 'XRCoordinateSystemEvent');184}185// Code for loading test API in Chromium.186async function loadChromiumResources() {187 await loadScript('/resources/chromium/webxr-test-math-helper.js');188 await import('/resources/chromium/webxr-test.js');189 await loadScript('/resources/testdriver.js');190 await loadScript('/resources/testdriver-vendor.js');191 // This infrastructure is also used by Chromium-specific internal tests that192 // may need additional resources (e.g. internal API extensions), this allows193 // those tests to rely on this infrastructure while ensuring that no tests194 // make it into public WPTs that rely on APIs outside of the webxr test API.195 if (typeof(additionalChromiumResources) !== 'undefined') {196 for (const path of additionalChromiumResources) {197 await loadScript(path);198 }199 }200 xr_debug = navigator.xr.test.Debug;201}202function setupWebKitWebXRTestAPI() {203 // WebKit setup. The internals object is used by the WebKit test runner204 // to provide JS access to internal APIs. In this case it's used to205 // ensure that XRTest is only exposed to wpt tests.206 navigator.xr.test = internals.xrTest;207 return Promise.resolve();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1setupWebKitWebXRTestAPI();2testRunner.setWebXRPermission(true);3testRunner.setWebXRPermission(false);4testRunner.setWebXRPermission(true, true);5testRunner.setWebXRPermission(false, true);6testRunner.setWebXRPermission(true, false);7testRunner.setWebXRPermission(false, false);8testRunner.setWebXRPermission(true, true, true);9testRunner.setWebXRPermission(false, true, true);10testRunner.setWebXRPermission(true, false, true);11testRunner.setWebXRPermission(false, false, true);12testRunner.setWebXRPermission(true, true, false);13testRunner.setWebXRPermission(false, true, false);14testRunner.setWebXRPermission(true, false, false);15testRunner.setWebXRPermission(false, false, false);16testRunner.setWebXRPermission(true, true, true, true);17testRunner.setWebXRPermission(false, true, true, true);18testRunner.setWebXRPermission(true, false, true, true);19testRunner.setWebXRPermission(false, false, true, true);20testRunner.setWebXRPermission(true, true, false, true);21testRunner.setWebXRPermission(false, true, false, true);

Full Screen

Using AI Code Generation

copy

Full Screen

1setupWebKitWebXRTestAPI().then(() => {2});3setupWebKitWebXRTestAPI().then(() => {4});5testAPI.setWebXRDevice(device)6testAPI.setWebXRDevice(device)7testAPI.isWebXRDeviceAvailable()

Full Screen

Using AI Code Generation

copy

Full Screen

1function setupWebKitWebXRTestAPI() {2 if (window.testRunner) {3 testRunner.setWebXRTestAPIEnabled(true);4 testRunner.setWebXRTestAPIMode('immersive-ar');5 }6}7setupWebKitWebXRTestAPI();8function setupWebKitWebXRTestAPI() {9 if (window.testRunner) {10 testRunner.setWebXRTestAPIEnabled(true);11 testRunner.setWebXRTestAPIMode('immersive-vr');12 }13}14setupWebKitWebXRTestAPI();15function setupWebKitWebXRTestAPI() {16 if (window.testRunner) {17 testRunner.setWebXRTestAPIEnabled(true);18 testRunner.setWebXRTestAPIMode('immersive-vr');19 testRunner.setWebXRTestAPIOriginOffset(0, 0, 0);20 }21}22setupWebKitWebXRTestAPI();23function setupWebKitWebXRTestAPI() {24 if (window.testRunner) {25 testRunner.setWebXRTestAPIEnabled(true);26 testRunner.setWebXRTestAPIMode('immersive-vr');27 testRunner.setWebXRTestAPIOriginOffset(10, 10, 10);28 }29}30setupWebKitWebXRTestAPI();31function setupWebKitWebXRTestAPI() {32 if (window.testRunner) {33 testRunner.setWebXRTestAPIEnabled(true);34 testRunner.setWebXRTestAPIMode('immersive-vr');35 testRunner.setWebXRTestAPIOriginOffset(10, 10, 10);36 testRunner.setWebXRTestAPIDisplayTransform(1, 0, 0, 0, 1, 0, 0, 0, 1);37 }38}39setupWebKitWebXRTestAPI();40function setupWebKitWebXRTestAPI() {41 if (window.testRunner) {42 testRunner.setWebXRTestAPIEnabled(true);43 testRunner.setWebXRTestAPIMode('immersive-vr');

Full Screen

Using AI Code Generation

copy

Full Screen

1function setupWebKitWebXRTestAPI() {2 window.testRunner = {3 setWebXRDeviceEnabled: function(enabled) {4 }5 };6}

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful