Skip to content

Commit

Permalink
Add more canvas context methods (#96)
Browse files Browse the repository at this point in the history
* Add more canvas context methods

* Fix test snippets for webgl2 apis

* Fix api tests

---------

Co-authored-by: Jonathan Kingston <[email protected]>
  • Loading branch information
muodov and jonathanKingston authored Jul 13, 2023
1 parent 3e9f49e commit 091e461
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
67 changes: 66 additions & 1 deletion collectors/APICalls/breakpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ const breakpoints = [
{
name: 'toDataURL',
test: 'var c = document.createElement("canvas"); c.toDataURL()'
},
{
name: 'toBlob',
test: 'var c = document.createElement("canvas"); c.toBlob()'
}
]
},
Expand All @@ -252,7 +256,7 @@ const breakpoints = [
name: 'getImageData',
test: 'var c = document.createElement("canvas"); var ctx = c.getContext("2d"); ctx.getImageData();'
},
//used to detect canvas winding
// used to detect canvas winding
{
name: 'isPointInPath',
test: 'var c = document.createElement("canvas"); var ctx = c.getContext("2d"); ctx.rect(10, 10, 100, 100); ctx.fill(); ctx.isPointInPath(30, 70);'
Expand Down Expand Up @@ -330,6 +334,67 @@ const breakpoints = [
name: 'getContextAttributes',
test: 'var c = document.createElement("canvas"); c.getContext("webgl").getContextAttributes()'
},
{
name: 'readPixels',
test: 'var c = document.createElement("canvas"); c.getContext("webgl").readPixels(0, 0, 1, 1, WebGLRenderingContext.RGBA, WebGLRenderingContext.UNSIGNED_BYTE, new Uint8Array(4))'
}
]
},
{
proto: 'WebGL2RenderingContext',
props: [
// {name: 'ALIASED_LINE_WIDTH_RANGE'}// we can't track static values
// 'WebGLRenderingContext.ALIASED_LINE_WIDTH_RANGE',
// 'WebGLRenderingContext.ALPHA_BITS',
// 'WebGLRenderingContext.BLUE_BITS',
// 'WebGLRenderingContext.DEPTH_BITS',
// 'WebGLRenderingContext.GREEN_BITS',
// 'WebGLRenderingContext.RED_BITS',
// 'WebGLRenderingContext.MAX_COMBINED_TEXTURE_IMAGE_UNITS',
// 'WebGLRenderingContext.MAX_CUBE_MAP_TEXTURE_SIZE',
// 'WebGLRenderingContext.MAX_FRAGMENT_UNIFORM_VECTORS',
// 'WebGLRenderingContext.MAX_RENDERBUFFER_SIZE',
// 'WebGLRenderingContext.MAX_TEXTURE_IMAGE_UNITS',
// 'WebGLRenderingContext.MAX_TEXTURE_SIZE',
// 'WebGLRenderingContext.MAX_VARYING_VECTORS',
// 'WebGLRenderingContext.MAX_VERTEX_ATTRIBS',
// 'WebGLRenderingContext.MAX_VERTEX_TEXTURE_IMAGE_UNITS',
// 'WebGLRenderingContext.MAX_VERTEX_UNIFORM_VECTORS',
// 'WebGLRenderingContext.MAX_VIEWPORT_DIMS',
// 'WebGLRenderingContext.RENDERER',
// 'WebGLRenderingContext.SHADING_LANGUAGE_VERSION',
// 'WebGLRenderingContext.VENDOR',
// 'WebGLRenderingContext.VERSION',
// 'WebGLRenderingContext.VERTEX_SHADER',
// 'WebGLRenderingContext.FRAGMENT_SHADER',
// 'WebGLRenderingContext.COLOR_BUFFER_BIT',
// 'WebGLRenderingContext.DEPTH_BUFFER_BIT'
],
methods: [
{
name: 'getSupportedExtensions',
test: 'var c = document.createElement("canvas"); c.getContext("webgl2").getSupportedExtensions()'
},
{
name: 'getExtension',
test: 'var c = document.createElement("canvas"); c.getContext("webgl2").getExtension("")'
},
{
name: 'getParameter',
test: 'var c = document.createElement("canvas"); c.getContext("webgl2").getParameter("")'
},
{
name: 'getShaderPrecisionFormat',
test: 'var c = document.createElement("canvas"); c.getContext("webgl2").getShaderPrecisionFormat(WebGLRenderingContext.FRAGMENT_SHADER, WebGLRenderingContext.LOW_FLOAT)'
},
{
name: 'getContextAttributes',
test: 'var c = document.createElement("canvas"); c.getContext("webgl2").getContextAttributes()'
},
{
name: 'readPixels',
test: 'var c = document.createElement("canvas"); c.getContext("webgl2").readPixels(0, 0, 1, 1, WebGLRenderingContext.RGBA, WebGLRenderingContext.UNSIGNED_BYTE, new Uint8Array(4))'
}
]
},
{
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/apiCollection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,17 @@ async function main() {
// method calls
"Document.prototype.interestCohort",
'HTMLCanvasElement.prototype.constructor',
'HTMLCanvasElement.prototype.toBlob',
'CanvasRenderingContext2D.prototype.isPointInPath',
'Date.prototype.getTime',
'WebGLRenderingContext.prototype.getExtension',
'WebGLRenderingContext.prototype.readPixels',
'WebGL2RenderingContext.prototype.getContextAttributes',
'WebGL2RenderingContext.prototype.getExtension',
'WebGL2RenderingContext.prototype.getParameter',
'WebGL2RenderingContext.prototype.getShaderPrecisionFormat',
'WebGL2RenderingContext.prototype.getSupportedExtensions',
'WebGL2RenderingContext.prototype.readPixels',
'AudioWorkletNode.prototype.constructor',
'SharedWorker.prototype.constructor',
'BroadcastChannel.prototype.constructor',
Expand Down

0 comments on commit 091e461

Please sign in to comment.