How to use testGLCanvas method in wpt

Best JavaScript code snippet using wpt

videoFrame-texImage.any.js

Source:videoFrame-texImage.any.js Github

copy

Full Screen

1// META: global=window,dedicatedworker2// META: script=/webcodecs/utils.js3// META: script=/webcodecs/webgl-test-utils.js4function testGLCanvas(gl, width, height, expectedPixel, assertCompares) {5 var colorData =6 new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4);7 gl.readPixels(8 0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA,9 gl.UNSIGNED_BYTE, colorData);10 assertCompares(gl.getError(), gl.NO_ERROR);11 const kMaxPixelToCheck = 128 * 96;12 let step = width * height / kMaxPixelToCheck;13 step = Math.round(step);14 step = (step < 1) ? 1 : step;15 for (let i = 0; i < 4 * width * height; i += (4 * step)) {16 assertCompares(colorData[i], expectedPixel[0]);17 assertCompares(colorData[i + 1], expectedPixel[1]);18 assertCompares(colorData[i + 2], expectedPixel[2]);19 assertCompares(colorData[i + 3], expectedPixel[3]);20 }21}22function testTexImage2DFromVideoFrame(23 width, height, useTexSubImage2D, expectedPixel) {24 let vfInit = {format: 'RGBA', timestamp: 0, codedWidth: width,25 codedHeight: height};26 let argbData = new Uint32Array(vfInit.codedWidth * vfInit.codedHeight);27 argbData.fill(0xFF966432); // 'rgb(50, 100, 150)';28 let frame = new VideoFrame(argbData, vfInit);29 let gl_canvas = new OffscreenCanvas(width, height);30 let gl = gl_canvas.getContext('webgl');31 let program = WebGLTestUtils.setupTexturedQuad(gl);32 gl.clearColor(0, 0, 0, 1);33 gl.clearDepth(1);34 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);35 gl.colorMask(1, 1, 1, 0); // Disable any writes to the alpha channel.36 let textureLoc = gl.getUniformLocation(program, 'tex');37 let texture = gl.createTexture();38 // Bind the texture to texture unit 0.39 gl.bindTexture(gl.TEXTURE_2D, texture);40 // Set up texture parameters.41 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);42 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);43 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);44 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);45 // Set up pixel store parameters.46 gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);47 gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);48 // Upload the videoElement into the texture49 if (useTexSubImage2D) {50 // Initialize the texture to black first51 gl.texImage2D(52 gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE,53 null);54 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, frame);55 } else {56 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, frame);57 }58 frame.close();59 assert_equals(gl.getError(), gl.NO_ERROR);60 // Point the uniform sampler to texture unit 061 gl.uniform1i(textureLoc, 0);62 // Draw the triangles63 WebGLTestUtils.drawQuad(gl, [0, 0, 0, 255]);64 // Wait for drawing to complete.65 gl.finish();66 testGLCanvas(gl, width, height, expectedPixel, assert_equals);67}68test(() => {69 return testTexImage2DFromVideoFrame(48, 36, false, kSRGBPixel);70}, 'drawImage(VideoFrame) with texImage2D (48x36) srgb.');71test(() => {72 return testTexImage2DFromVideoFrame(48, 36, true, kSRGBPixel);73}, 'drawImage(VideoFrame) with texSubImage2D (48x36) srgb.');74test(() => {75 return testTexImage2DFromVideoFrame(480, 360, false, kSRGBPixel);76}, 'drawImage(VideoFrame) with texImage2D (480x360) srgb.');77test(() => {78 return testTexImage2DFromVideoFrame(480, 360, true, kSRGBPixel);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var canvas = document.getElementById('canvas');2var gl = canvas.getContext('webgl');3if (gl == null) {4 gl = canvas.getContext('experimental-webgl');5}6if (gl == null) {7 testFailed('WebGL not supported');8} else {9 var result = testGLCanvas(gl);10 testPassed('WebGL supported');11 testPassed('WebGL context successfully created');12 testPassed('WebGL canvas successfully initialized');13}14)HTML");15 RunWebGLTest("test.html", "WebGL supported");16}17TEST_F(WebGLTest, WebGL2Supported) {18 SetBodyInnerHTML(R"HTML(19var canvas = document.getElementById('canvas');20var gl = canvas.getContext('webgl2');21if (gl == null) {22 gl = canvas.getContext('experimental-webgl2');23}24if (gl == null) {25 testFailed('WebGL 2.0 not supported');26} else {27 var result = testGLCanvas(gl);28 testPassed('WebGL 2.0 supported');29 testPassed('WebGL 2.0 context successfully created');30 testPassed('WebGL 2.0 canvas successfully initialized');31}32)HTML");33 RunWebGLTest("test.html", "WebGL 2.0 supported");34}35TEST_F(WebGLTest, WebGL2SupportedWithWebGL1Context) {36 SetBodyInnerHTML(R"HTML(37var canvas = document.getElementById('canvas');38var gl = canvas.getContext('webgl');39if (gl == null) {40 gl = canvas.getContext('experimental-webgl');41}42if (gl == null) {43 testFailed('WebGL not supported');44} else {45 var result = testGLCanvas(gl);46 testPassed('WebGL supported');47 testPassed('WebGL context successfully created');48 testPassed('WebGL canvas successfully initialized');49}50)HTML");51 RunWebGLTest("test.html", "WebGL supported");52}53TEST_F(WebGLTest, WebGL2SupportedWithWebGL2Context) {

Full Screen

Using AI Code Generation

copy

Full Screen

1testGLCanvas("canvas", "webgl", "rgba(0, 0, 255, 1)", "rgba(0, 0, 0, 0)");2)HTML");3 NavigateToURL(shell(), url);4 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));5 EXPECT_EQ("PASS", EvalJs(shell(), "window.glResult"));6}7IN_PROC_BROWSER_TEST_F(WebGLBrowserTest, HiddenCanvas) {8 GURL url(embedded_test_server()->GetURL(9 "/webgl/conformance-1.0.3/conformance/attribs/gl-viewport.html"));10 NavigateToURL(shell(), url);11 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));12 EXPECT_EQ("PASS", EvalJs(shell(), "document.getElementById('hidden').style."13 "visibility = 'hidden';"14 "window.glResult"));15 EXPECT_EQ("PASS", EvalJs(shell(), "document.getElementById('hidden').style."16 "visibility = 'visible';"17 "window.glResult"));18}19IN_PROC_BROWSER_TEST_F(WebGLBrowserTest, HiddenCanvasWithWebGLContext) {20 GURL url(embedded_test_server()->GetURL(21 "/webgl/conformance-1.0.3/conformance/attribs/gl-viewport.html"));22 NavigateToURL(shell(), url);23 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));24 EXPECT_EQ("PASS", EvalJs(shell(), "window.glResult"));25 EXPECT_EQ("PASS", EvalJs(shell(), "document.getElementById('hidden').style."26 "visibility = 'hidden';"27 "window.glResult"));28 EXPECT_EQ("PASS", EvalJs(shell(), "document.getElementById('hidden').style."29 "visibility = 'visible';"30 "window.glResult"));31}32IN_PROC_BROWSER_TEST_F(WebGLBrowserTest, HiddenCanvasWithWebGLContext2) {33 GURL url(embedded_test_server()->GetURL(

Full Screen

Using AI Code Generation

copy

Full Screen

1testGLCanvas('canvas', '2d', 'webgl', 'webgl2', 'webgl-experimental', 'webgl2-experimental');2testGLCanvas('canvas', '2d', 'webgl', 'webgl2', 'webgl-experimental', 'webgl2-experimental');3testGLCanvas('canvas', '2d', 'webgl', 'webgl2', 'webgl-experimental', 'webgl2-experimental');4testGLCanvas('canvas', '2d', 'webgl', 'webgl2', 'webgl-experimental', 'webgl2-experimental');5testGLCanvas('canvas', '2d', 'webgl', 'webgl2', 'webgl-experimental', 'webgl2-experimental');6testGLCanvas('canvas', '2d', 'webgl', 'webgl2', 'webgl-experimental', 'webgl2-experimental');7testGLCanvas('canvas', '2d', 'webgl', 'webgl2', 'webgl-experimental', 'webgl2-experimental');8testGLCanvas('canvas', '2d', 'webgl', 'webgl2', 'webgl-experimental', 'webgl2-experimental');9testGLCanvas('canvas', '2d', 'webgl', 'webgl2', 'webgl-experimental', 'webgl2-experimental');10testGLCanvas('canvas', '2d', 'webgl', 'webgl2', 'webgl-experimental', 'webgl2-experimental');11testGLCanvas('canvas', '2d',

Full Screen

Using AI Code Generation

copy

Full Screen

1var canvas = document.getElementById("canvas");2var gl = canvas.getContext("experimental-webgl");3var wpt = new WebGLPerfTest();4var test = wpt.testGLCanvas(gl, canvas);5if (test) {6 console.log('Test Pass');7} else {8 console.log('Test Fail');9}10### WebGLPerfTest()11### WebGLPerfTest.testGLCanvas(gl, canvas)12WebGLPerfTest is available under the [Apache 2.0 license](

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.testGLCanvas(function(err, result) {3 console.log("testGLCanvas result: " + result);4});5var wpt = require('wpt');6wpt.testVideo(function(err, result) {7 console.log("testVideo result: " + result);8});9var wpt = require('wpt');10wpt.testWebAudio(function(err, result) {11 console.log("testWebAudio result: " + result);12});13var wpt = require('wpt');14wpt.testWebSockets(function(err, result) {15 console.log("testWebSockets result: " + result);16});17var wpt = require('wpt');18wpt.testWebGL(function(err, result) {19 console.log("testWebGL result: " + result);20});21var wpt = require('wpt');22wpt.testWebRTC(function(err, result) {23 console.log("testWebRTC result: " + result);24});25var wpt = require('wpt');26wpt.testWebSQL(function(err, result) {27 console.log("testWebSQL result: " + result);28});29var wpt = require('wpt');30wpt.testWebSocket(function(err, result) {31 console.log("testWebSocket result: " + result);32});33var wpt = require('

Full Screen

Using AI Code Generation

copy

Full Screen

1var test = async_test("testGLCanvas");2test.step(function(){3 wptTestDriver.testGLCanvas(function (result) {4 assert_true(result);5 test.done();6 });7});

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