How to use glcontextProperties method in wpt

Best JavaScript code snippet using wpt

webxr_util.js

Source:webxr_util.js Github

copy

Full Screen

1'use strict';2// These tests rely on the User Agent providing an implementation of the3// WebXR Testing API (https://github.com/immersive-web/webxr-test-api).4//5// In Chromium-based browsers, this implementation is provided by a JavaScript6// shim in order to reduce the amount of test-only code shipped to users. To7// enable these tests the browser must be run with these options:8//9// --enable-blink-features=MojoJS,MojoJSTest10// Debugging message helper, by default does nothing. Implementations can11// override this.12var xr_debug = function(name, msg) {};13function xr_promise_test(name, func, properties, glContextType, glContextProperties) {14 promise_test(async (t) => {15 // Perform any required test setup:16 xr_debug(name, 'setup');17 assert_implements(navigator.xr, 'missing navigator.xr');18 // Only set up once.19 if (!navigator.xr.test) {20 // Load test-only API helpers.21 const script = document.createElement('script');22 script.src = '/resources/test-only-api.js';23 script.async = false;24 const p = new Promise((resolve, reject) => {25 script.onload = () => { resolve(); };26 script.onerror = e => { reject(e); };27 })28 document.head.appendChild(script);29 await p;30 if (isChromiumBased) {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

1importScripts('/resources/testharness.js');2importScripts('/resources/testharnessreport.js');3importScripts('/webgl/resources/webgl-test-utils.js');4test(function() {5 var canvas = document.createElement('canvas');6 var gl = canvas.getContext('webgl', {antialias: false});7 assert_true(gl !== null);8 assert_true(gl instanceof WebGLRenderingContext);9 assert_equals(gl.canvas, canvas);10 assert_equals(gl.drawingBufferWidth, 300);11 assert_equals(gl.drawingBufferHeight, 150);12 assert_equals(gl.getContextAttributes().antialias, false);13}, "glcontextProperties");14done();15I think it is better to use canvas.getContext('webgl', {antialias: false}); in the testharness.js file. I also think that the webgl-test-utils.js file should be used to test the webgl-test-utils

Full Screen

Using AI Code Generation

copy

Full Screen

1var gl = wpt.glcontextProperties({2});3var gl = wpt.glcontextProperties({4});5var gl = wpt.glcontextProperties({6});7var gl = wpt.glcontextProperties({8});9var gl = wpt.glcontextProperties({10});11var gl = wpt.glcontextProperties({12});

Full Screen

Using AI Code Generation

copy

Full Screen

1var canvas = document.getElementById("canvas");2var gl = canvas.getContext("webgl", {glcontextProperties: true});3var glprops = gl.getExtension("WEBGL_glcontext_properties");4var glprops2 = gl.getExtension("WEBGL_glcontext_properties");5var glprops3 = gl.getExtension("WEBGL_glcontext_properties");6var glprops4 = gl.getExtension("WEBGL_glcontext_properties");7var glprops5 = gl.getExtension("WEBGL_glcontext_properties");8console.log(glprops);9console.log(glprops2);10console.log(glprops3);11console.log(glprops4);12console.log(glprops5);13 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptRunner = require('wpt-runner');2const path = require('path');3const fs = require('fs');4const options = {5 outputDir: path.resolve(__dirname, 'test'),6 glContextProperties: {7 },8 glContextAttributes: {9 },10 viewportSize: {11 }12};13wptRunner(options).then(() => {14});15{16 "scripts": {17 },18 "dependencies": {19 }20}

Full Screen

Using AI Code Generation

copy

Full Screen

1importScripts('glcontextproperties.js');2var canvas = document.createElement('canvas');3var gl = canvas.getContext('webgl2', wpt.glContextProperties());4if (gl) {5 postMessage('WebGL 2.0 supported');6} else {7 postMessage('WebGL 2.0 not supported');8}9The wpt.glContextProperties() method returns an object with the following properties:10The wpt.glContextProperties() method also returns an object with the following properties:11The wpt.glContextProperties() method returns an object with the following properties:12The wpt.glContextProperties() method also returns an object with the following properties:

Full Screen

Using AI Code Generation

copy

Full Screen

1var canvas = document.createElement('canvas');2var gl = canvas.getContext('webgl', { glcontextProperties: true });3var props = gl.getContextProperties();4var contextName = props['glcontextName'];5var contextVersion = props['glcontextVersion'];6var contextFlags = props['glcontextFlags'];7var contextProfileMask = props['glcontextProfileMask'];8var contextRenderer = props['glcontextRenderer'];9var contextVendor = props['glcontextVendor'];10var contextExtensions = props['glcontextExtensions'];11var contextGLVersion = props['glcontextGLVersion'];12var contextShadingLanguageVersion = props['glcontextShadingLanguageVersion'];

Full Screen

Using AI Code Generation

copy

Full Screen

1var canvas = document.createElement("canvas");2var gl = canvas.getContext("webgl", {alpha:false, depth:false, stencil:false, antialias:false, premultipliedAlpha:false, preserveDrawingBuffer:false, failIfMajorPerformanceCaveat:true});3if (gl != null) {4 console.log("webgl context created successfully");5} else {6 console.log("webgl context creation failed");7}8var canvas = document.createElement("canvas");9var gl = canvas.getContext("webgl", {alpha:false, depth:false, stencil:false, antialias:false, premultipliedAlpha:false, preserveDrawingBuffer:false, failIfMajorPerformanceCaveat:true});10if (gl != null) {11 console.log("webgl context created successfully");12} else {13 console.log("webgl context creation failed");14}15var canvas = document.createElement("canvas");16var gl = canvas.getContext("webgl", {alpha:false, depth:false, stencil:false, antialias:false, premultipliedAlpha:false, preserveDrawingBuffer:false, failIfMajorPerformanceCaveat:true});17if (gl != null) {18 console.log("webgl context created successfully");19} else {20 console.log("webgl context creation failed");21}22var canvas = document.createElement("canvas");23var gl = canvas.getContext("webgl", {alpha:false, depth:false, stencil:false, antialias:false, premultipliedAlpha:false, preserveDrawingBuffer:false, failIfMajorPerformanceCaveat:true});24if (gl != null) {25 console.log("webgl context created successfully");26} else {27 console.log("webgl context creation failed");28}29var canvas = document.createElement("canvas");30var gl = canvas.getContext("webgl", {alpha:false, depth:false, stencil:false, antialias:false, premultipliedAlpha:false, preserveDrawingBuffer:false, failIfMajorPerformanceCaveat:true});31if (gl != null) {32 console.log("webgl context created successfully");33} else {34 console.log("webgl context creation failed");35}36var canvas = document.createElement("canvas");37var gl = canvas.getContext("webgl", {alpha:false, depth:false, stencil:false, antialias:false, premultipliedAlpha:false, preserveDrawingBuffer:false, failIfMajorPerformanceCaveat:true});38if (gl != null) {39 console.log("webgl context created successfully");40} else {41 console.log("web

Full Screen

Using AI Code Generation

copy

Full Screen

1var gl = wpt.glcontextProperties();2var canvas = gl.canvas;3var context = gl.context;4var attributes = gl.attributes;5assert_true(canvas instanceof HTMLCanvasElement);6assert_true(context instanceof WebGLRenderingContext);7assert_true(attributes instanceof WebGLContextAttributes);8var gl = wpt.glcontextProperties();9var canvas = gl.canvas;10var context = gl.context;11var attributes = gl.attributes;12assert_true(canvas instanceof HTMLCanvasElement);13assert_true(context instanceof WebGLRenderingContext);14assert_true(attributes instanceof WebGLContextAttributes);

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