Add WebGL Conformance Tests canvas folder.
authorgman@chromium.org <gman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2013 12:39:03 +0000 (12:39 +0000)
committergman@chromium.org <gman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2013 12:39:03 +0000 (12:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=109113

Reviewed by Kenneth Russell.

* webgl/conformance/canvas/canvas-test-expected.txt: Added.
* webgl/conformance/canvas/canvas-test.html: Added.
* webgl/conformance/canvas/canvas-zero-size-expected.txt: Added.
* webgl/conformance/canvas/canvas-zero-size.html: Added.
* webgl/conformance/canvas/drawingbuffer-hd-dpi-test-expected.txt: Added.
* webgl/conformance/canvas/drawingbuffer-hd-dpi-test.html: Added.
* webgl/conformance/canvas/drawingbuffer-static-canvas-test-expected.txt: Added.
* webgl/conformance/canvas/drawingbuffer-static-canvas-test.html: Added.
* webgl/conformance/canvas/framebuffer-bindings-unaffected-on-resize-expected.txt: Added.
* webgl/conformance/canvas/framebuffer-bindings-unaffected-on-resize.html: Added.
* webgl/conformance/canvas/texture-bindings-unaffected-on-resize-expected.txt: Added.
* webgl/conformance/canvas/texture-bindings-unaffected-on-resize.html: Added.
* webgl/conformance/canvas/viewport-unchanged-upon-resize-expected.txt: Added.
* webgl/conformance/canvas/viewport-unchanged-upon-resize.html: Added.
* webgl/resources/webgl_test_files/conformance/canvas/00_test_list.txt: Added.
* webgl/resources/webgl_test_files/conformance/canvas/canvas-test.html: Added.
* webgl/resources/webgl_test_files/conformance/canvas/canvas-zero-size.html: Added.
* webgl/resources/webgl_test_files/conformance/canvas/drawingbuffer-hd-dpi-test.html: Added.
* webgl/resources/webgl_test_files/conformance/canvas/drawingbuffer-static-canvas-test.html: Added.
* webgl/resources/webgl_test_files/conformance/canvas/framebuffer-bindings-unaffected-on-resize.html: Added.
* webgl/resources/webgl_test_files/conformance/canvas/texture-bindings-unaffected-on-resize.html: Added.
* webgl/resources/webgl_test_files/conformance/canvas/viewport-unchanged-upon-resize.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142096 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
LayoutTests/ChangeLog
LayoutTests/webgl/conformance/canvas/canvas-test-expected.txt [new file with mode: 0644]
LayoutTests/webgl/conformance/canvas/canvas-test.html [new file with mode: 0644]
LayoutTests/webgl/conformance/canvas/canvas-zero-size-expected.txt [new file with mode: 0644]
LayoutTests/webgl/conformance/canvas/canvas-zero-size.html [new file with mode: 0644]
LayoutTests/webgl/conformance/canvas/drawingbuffer-hd-dpi-test-expected.txt [new file with mode: 0644]
LayoutTests/webgl/conformance/canvas/drawingbuffer-hd-dpi-test.html [new file with mode: 0644]
LayoutTests/webgl/conformance/canvas/drawingbuffer-static-canvas-test-expected.txt [new file with mode: 0644]
LayoutTests/webgl/conformance/canvas/drawingbuffer-static-canvas-test.html [new file with mode: 0644]
LayoutTests/webgl/conformance/canvas/framebuffer-bindings-unaffected-on-resize-expected.txt [new file with mode: 0644]
LayoutTests/webgl/conformance/canvas/framebuffer-bindings-unaffected-on-resize.html [new file with mode: 0644]
LayoutTests/webgl/conformance/canvas/texture-bindings-unaffected-on-resize-expected.txt [new file with mode: 0644]
LayoutTests/webgl/conformance/canvas/texture-bindings-unaffected-on-resize.html [new file with mode: 0644]
LayoutTests/webgl/conformance/canvas/viewport-unchanged-upon-resize-expected.txt [new file with mode: 0644]
LayoutTests/webgl/conformance/canvas/viewport-unchanged-upon-resize.html [new file with mode: 0644]
LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/00_test_list.txt [new file with mode: 0644]
LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/canvas-test.html [new file with mode: 0644]
LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/canvas-zero-size.html [new file with mode: 0644]
LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/drawingbuffer-hd-dpi-test.html [new file with mode: 0644]
LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/drawingbuffer-static-canvas-test.html [new file with mode: 0644]
LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/framebuffer-bindings-unaffected-on-resize.html [new file with mode: 0644]
LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/texture-bindings-unaffected-on-resize.html [new file with mode: 0644]
LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/viewport-unchanged-upon-resize.html [new file with mode: 0644]

index 24c52be..69ee67f 100644 (file)
@@ -1,5 +1,35 @@
 2013-02-07  Gregg Tavares  <gman@chromium.org>
 
+        Add WebGL Conformance Tests canvas folder.
+        https://bugs.webkit.org/show_bug.cgi?id=109113
+
+        Reviewed by Kenneth Russell.
+
+        * webgl/conformance/canvas/canvas-test-expected.txt: Added.
+        * webgl/conformance/canvas/canvas-test.html: Added.
+        * webgl/conformance/canvas/canvas-zero-size-expected.txt: Added.
+        * webgl/conformance/canvas/canvas-zero-size.html: Added.
+        * webgl/conformance/canvas/drawingbuffer-hd-dpi-test-expected.txt: Added.
+        * webgl/conformance/canvas/drawingbuffer-hd-dpi-test.html: Added.
+        * webgl/conformance/canvas/drawingbuffer-static-canvas-test-expected.txt: Added.
+        * webgl/conformance/canvas/drawingbuffer-static-canvas-test.html: Added.
+        * webgl/conformance/canvas/framebuffer-bindings-unaffected-on-resize-expected.txt: Added.
+        * webgl/conformance/canvas/framebuffer-bindings-unaffected-on-resize.html: Added.
+        * webgl/conformance/canvas/texture-bindings-unaffected-on-resize-expected.txt: Added.
+        * webgl/conformance/canvas/texture-bindings-unaffected-on-resize.html: Added.
+        * webgl/conformance/canvas/viewport-unchanged-upon-resize-expected.txt: Added.
+        * webgl/conformance/canvas/viewport-unchanged-upon-resize.html: Added.
+        * webgl/resources/webgl_test_files/conformance/canvas/00_test_list.txt: Added.
+        * webgl/resources/webgl_test_files/conformance/canvas/canvas-test.html: Added.
+        * webgl/resources/webgl_test_files/conformance/canvas/canvas-zero-size.html: Added.
+        * webgl/resources/webgl_test_files/conformance/canvas/drawingbuffer-hd-dpi-test.html: Added.
+        * webgl/resources/webgl_test_files/conformance/canvas/drawingbuffer-static-canvas-test.html: Added.
+        * webgl/resources/webgl_test_files/conformance/canvas/framebuffer-bindings-unaffected-on-resize.html: Added.
+        * webgl/resources/webgl_test_files/conformance/canvas/texture-bindings-unaffected-on-resize.html: Added.
+        * webgl/resources/webgl_test_files/conformance/canvas/viewport-unchanged-upon-resize.html: Added.
+
+2013-02-07  Gregg Tavares  <gman@chromium.org>
+
         Add WebGL Conformance Tests texture folder.
         https://bugs.webkit.org/show_bug.cgi?id=109111
 
diff --git a/LayoutTests/webgl/conformance/canvas/canvas-test-expected.txt b/LayoutTests/webgl/conformance/canvas/canvas-test-expected.txt
new file mode 100644 (file)
index 0000000..042190e
--- /dev/null
@@ -0,0 +1,5 @@
+This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.
+
+Test: ../../resources/webgl_test_files/conformance/canvas/canvas-test.html
+PASS
+
diff --git a/LayoutTests/webgl/conformance/canvas/canvas-test.html b/LayoutTests/webgl/conformance/canvas/canvas-test.html
new file mode 100644 (file)
index 0000000..46c6940
--- /dev/null
@@ -0,0 +1,18 @@
+<!-- This file is auto-generated by generate-webgl-tests.py. DO NOT EDIT -->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Conformance Test Wrapper for canvas-test.html</title>
+<script type="text/javascript" src="../../../fast/js/resources/js-test-pre.js"></script>
+<script type="text/javascript" src="../../resources/webkit-webgl-test-harness.js"></script>
+</head>
+<body>
+<p>This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.</p>
+Test: <a href="../../resources/webgl_test_files/conformance/canvas/canvas-test.html">../../resources/webgl_test_files/conformance/canvas/canvas-test.html</a>
+<div id="result"></div>
+<div id="iframe">
+<iframe src="../../resources/webgl_test_files/conformance/canvas/canvas-test.html" width="800" height="600"></iframe>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/webgl/conformance/canvas/canvas-zero-size-expected.txt b/LayoutTests/webgl/conformance/canvas/canvas-zero-size-expected.txt
new file mode 100644 (file)
index 0000000..b1619bc
--- /dev/null
@@ -0,0 +1,5 @@
+This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.
+
+Test: ../../resources/webgl_test_files/conformance/canvas/canvas-zero-size.html
+PASS
+
diff --git a/LayoutTests/webgl/conformance/canvas/canvas-zero-size.html b/LayoutTests/webgl/conformance/canvas/canvas-zero-size.html
new file mode 100644 (file)
index 0000000..414623e
--- /dev/null
@@ -0,0 +1,18 @@
+<!-- This file is auto-generated by generate-webgl-tests.py. DO NOT EDIT -->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Conformance Test Wrapper for canvas-zero-size.html</title>
+<script type="text/javascript" src="../../../fast/js/resources/js-test-pre.js"></script>
+<script type="text/javascript" src="../../resources/webkit-webgl-test-harness.js"></script>
+</head>
+<body>
+<p>This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.</p>
+Test: <a href="../../resources/webgl_test_files/conformance/canvas/canvas-zero-size.html">../../resources/webgl_test_files/conformance/canvas/canvas-zero-size.html</a>
+<div id="result"></div>
+<div id="iframe">
+<iframe src="../../resources/webgl_test_files/conformance/canvas/canvas-zero-size.html" width="800" height="600"></iframe>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/webgl/conformance/canvas/drawingbuffer-hd-dpi-test-expected.txt b/LayoutTests/webgl/conformance/canvas/drawingbuffer-hd-dpi-test-expected.txt
new file mode 100644 (file)
index 0000000..bbb96c2
--- /dev/null
@@ -0,0 +1,5 @@
+This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.
+
+Test: ../../resources/webgl_test_files/conformance/canvas/drawingbuffer-hd-dpi-test.html
+PASS
+
diff --git a/LayoutTests/webgl/conformance/canvas/drawingbuffer-hd-dpi-test.html b/LayoutTests/webgl/conformance/canvas/drawingbuffer-hd-dpi-test.html
new file mode 100644 (file)
index 0000000..62113d3
--- /dev/null
@@ -0,0 +1,18 @@
+<!-- This file is auto-generated by generate-webgl-tests.py. DO NOT EDIT -->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Conformance Test Wrapper for drawingbuffer-hd-dpi-test.html</title>
+<script type="text/javascript" src="../../../fast/js/resources/js-test-pre.js"></script>
+<script type="text/javascript" src="../../resources/webkit-webgl-test-harness.js"></script>
+</head>
+<body>
+<p>This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.</p>
+Test: <a href="../../resources/webgl_test_files/conformance/canvas/drawingbuffer-hd-dpi-test.html">../../resources/webgl_test_files/conformance/canvas/drawingbuffer-hd-dpi-test.html</a>
+<div id="result"></div>
+<div id="iframe">
+<iframe src="../../resources/webgl_test_files/conformance/canvas/drawingbuffer-hd-dpi-test.html" width="800" height="600"></iframe>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/webgl/conformance/canvas/drawingbuffer-static-canvas-test-expected.txt b/LayoutTests/webgl/conformance/canvas/drawingbuffer-static-canvas-test-expected.txt
new file mode 100644 (file)
index 0000000..e035d81
--- /dev/null
@@ -0,0 +1,5 @@
+This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.
+
+Test: ../../resources/webgl_test_files/conformance/canvas/drawingbuffer-static-canvas-test.html
+PASS
+
diff --git a/LayoutTests/webgl/conformance/canvas/drawingbuffer-static-canvas-test.html b/LayoutTests/webgl/conformance/canvas/drawingbuffer-static-canvas-test.html
new file mode 100644 (file)
index 0000000..a71fa43
--- /dev/null
@@ -0,0 +1,18 @@
+<!-- This file is auto-generated by generate-webgl-tests.py. DO NOT EDIT -->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Conformance Test Wrapper for drawingbuffer-static-canvas-test.html</title>
+<script type="text/javascript" src="../../../fast/js/resources/js-test-pre.js"></script>
+<script type="text/javascript" src="../../resources/webkit-webgl-test-harness.js"></script>
+</head>
+<body>
+<p>This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.</p>
+Test: <a href="../../resources/webgl_test_files/conformance/canvas/drawingbuffer-static-canvas-test.html">../../resources/webgl_test_files/conformance/canvas/drawingbuffer-static-canvas-test.html</a>
+<div id="result"></div>
+<div id="iframe">
+<iframe src="../../resources/webgl_test_files/conformance/canvas/drawingbuffer-static-canvas-test.html" width="800" height="600"></iframe>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/webgl/conformance/canvas/framebuffer-bindings-unaffected-on-resize-expected.txt b/LayoutTests/webgl/conformance/canvas/framebuffer-bindings-unaffected-on-resize-expected.txt
new file mode 100644 (file)
index 0000000..464de72
--- /dev/null
@@ -0,0 +1,5 @@
+This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.
+
+Test: ../../resources/webgl_test_files/conformance/canvas/framebuffer-bindings-unaffected-on-resize.html
+PASS
+
diff --git a/LayoutTests/webgl/conformance/canvas/framebuffer-bindings-unaffected-on-resize.html b/LayoutTests/webgl/conformance/canvas/framebuffer-bindings-unaffected-on-resize.html
new file mode 100644 (file)
index 0000000..b89679c
--- /dev/null
@@ -0,0 +1,18 @@
+<!-- This file is auto-generated by generate-webgl-tests.py. DO NOT EDIT -->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Conformance Test Wrapper for framebuffer-bindings-unaffected-on-resize.html</title>
+<script type="text/javascript" src="../../../fast/js/resources/js-test-pre.js"></script>
+<script type="text/javascript" src="../../resources/webkit-webgl-test-harness.js"></script>
+</head>
+<body>
+<p>This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.</p>
+Test: <a href="../../resources/webgl_test_files/conformance/canvas/framebuffer-bindings-unaffected-on-resize.html">../../resources/webgl_test_files/conformance/canvas/framebuffer-bindings-unaffected-on-resize.html</a>
+<div id="result"></div>
+<div id="iframe">
+<iframe src="../../resources/webgl_test_files/conformance/canvas/framebuffer-bindings-unaffected-on-resize.html" width="800" height="600"></iframe>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/webgl/conformance/canvas/texture-bindings-unaffected-on-resize-expected.txt b/LayoutTests/webgl/conformance/canvas/texture-bindings-unaffected-on-resize-expected.txt
new file mode 100644 (file)
index 0000000..32b9dfe
--- /dev/null
@@ -0,0 +1,5 @@
+This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.
+
+Test: ../../resources/webgl_test_files/conformance/canvas/texture-bindings-unaffected-on-resize.html
+PASS
+
diff --git a/LayoutTests/webgl/conformance/canvas/texture-bindings-unaffected-on-resize.html b/LayoutTests/webgl/conformance/canvas/texture-bindings-unaffected-on-resize.html
new file mode 100644 (file)
index 0000000..af77c34
--- /dev/null
@@ -0,0 +1,18 @@
+<!-- This file is auto-generated by generate-webgl-tests.py. DO NOT EDIT -->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Conformance Test Wrapper for texture-bindings-unaffected-on-resize.html</title>
+<script type="text/javascript" src="../../../fast/js/resources/js-test-pre.js"></script>
+<script type="text/javascript" src="../../resources/webkit-webgl-test-harness.js"></script>
+</head>
+<body>
+<p>This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.</p>
+Test: <a href="../../resources/webgl_test_files/conformance/canvas/texture-bindings-unaffected-on-resize.html">../../resources/webgl_test_files/conformance/canvas/texture-bindings-unaffected-on-resize.html</a>
+<div id="result"></div>
+<div id="iframe">
+<iframe src="../../resources/webgl_test_files/conformance/canvas/texture-bindings-unaffected-on-resize.html" width="800" height="600"></iframe>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/webgl/conformance/canvas/viewport-unchanged-upon-resize-expected.txt b/LayoutTests/webgl/conformance/canvas/viewport-unchanged-upon-resize-expected.txt
new file mode 100644 (file)
index 0000000..6a2ce07
--- /dev/null
@@ -0,0 +1,5 @@
+This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.
+
+Test: ../../resources/webgl_test_files/conformance/canvas/viewport-unchanged-upon-resize.html
+PASS
+
diff --git a/LayoutTests/webgl/conformance/canvas/viewport-unchanged-upon-resize.html b/LayoutTests/webgl/conformance/canvas/viewport-unchanged-upon-resize.html
new file mode 100644 (file)
index 0000000..4b607a7
--- /dev/null
@@ -0,0 +1,18 @@
+<!-- This file is auto-generated by generate-webgl-tests.py. DO NOT EDIT -->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Conformance Test Wrapper for viewport-unchanged-upon-resize.html</title>
+<script type="text/javascript" src="../../../fast/js/resources/js-test-pre.js"></script>
+<script type="text/javascript" src="../../resources/webkit-webgl-test-harness.js"></script>
+</head>
+<body>
+<p>This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.</p>
+Test: <a href="../../resources/webgl_test_files/conformance/canvas/viewport-unchanged-upon-resize.html">../../resources/webgl_test_files/conformance/canvas/viewport-unchanged-upon-resize.html</a>
+<div id="result"></div>
+<div id="iframe">
+<iframe src="../../resources/webgl_test_files/conformance/canvas/viewport-unchanged-upon-resize.html" width="800" height="600"></iframe>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/00_test_list.txt b/LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/00_test_list.txt
new file mode 100644 (file)
index 0000000..6ad9bb6
--- /dev/null
@@ -0,0 +1,12 @@
+buffer-offscreen-test.html
+buffer-preserve-test.html
+canvas-test.html
+canvas-zero-size.html
+drawingbuffer-static-canvas-test.html
+--min-version 1.0.2 drawingbuffer-hd-dpi-test.html
+drawingbuffer-test.html
+--min-version 1.0.2 framebuffer-bindings-unaffected-on-resize.html
+--min-version 1.0.2 texture-bindings-unaffected-on-resize.html
+--min-version 1.0.2 to-data-url-test.html
+viewport-unchanged-upon-resize.html
+
diff --git a/LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/canvas-test.html b/LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/canvas-test.html
new file mode 100644 (file)
index 0000000..d8983ee
--- /dev/null
@@ -0,0 +1,215 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Canvas Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../resources/desktop-gl-constants.js" type="text/javascript"></script>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
+<canvas id="canvas2d" width="40" height="40"> </canvas>
+<script>
+"use strict";
+initTestingHarnessWaitUntilDone();
+
+description("This test ensures WebGL implementations interact correctly with the canvas tag.");
+
+debug("");
+debug("Canvas.getContext");
+
+var err;
+var wtu = WebGLTestUtils;
+var canvas = document.getElementById("canvas");
+var canvas2d = document.getElementById("canvas2d");
+var ctx2d = canvas2d.getContext("2d");
+var gl = wtu.create3DContext(canvas);
+if (!gl) {
+  testFailed("context does not exist");
+} else {
+  testPassed("context exists");
+
+  debug("");
+  debug("Checking canvas and WebGL interaction");
+
+  // Check that a canvas with no width or height is 300x150 pixels
+  shouldBe('canvas.width', '300');
+  shouldBe('canvas.height', '150');
+
+  // Check get a 4 value gl parameter as a csv string.
+  var getValue4v = function(name) {
+    var v = gl.getParameter(name);
+    var result = '' +
+        v[0] + ',' +
+        v[1] + ',' +
+        v[2] + ',' +
+        v[3];
+    return result;
+  }
+
+  var getViewport = function() {
+    return getValue4v(gl.VIEWPORT);
+  }
+
+  var getClearColor = function() {
+    return getValue4v(gl.COLOR_CLEAR_VALUE);
+  }
+
+  var isAboutEqual = function(a, b) {
+    return Math.abs(a - b) < 0.01;
+  }
+
+  var isAboutEqualInt = function(a, b) {
+    return Math.abs(a - b) < 3;
+  }
+
+  var checkCanvasContentIs = function(r3d,g3d,b3d,a3d) {
+    var r2d;
+    var g2d;
+    var b2d;
+    var a2d;
+
+    var checkPixel = function(x, y, r3d,g3d,b3d,a3d) {
+      var offset = (y * 40 + x) * 4;
+      r2d = imgData.data[offset];
+      g2d = imgData.data[offset + 1];
+      b2d = imgData.data[offset + 2];
+      a2d = imgData.data[offset + 3];
+      //debug('' + x + ', ' + y + "(" + offset + ") = " + r2d + ", " + g2d + ", " + b2d + ", " + a2d);
+      return isAboutEqualInt(r2d, r3d) &&
+             isAboutEqualInt(g2d, g3d) &&
+             isAboutEqualInt(b2d, b3d) &&
+             isAboutEqualInt(a2d, a3d);
+    }
+
+    var checkPixels = function(r3d,g3d,b3d,a3d) {
+      return checkPixel(0, 0, r3d, g3d, b3d, a3d) &&
+             checkPixel(0, 39, r3d, g3d, b3d, a3d) &&
+             checkPixel(39, 0, r3d, g3d, b3d, a3d) &&
+             checkPixel(39, 39, r3d, g3d, b3d, a3d) &&
+             checkPixel(0, 0, r3d, g3d, b3d, a3d);
+    };
+
+    // Set to just take the color from the 3d canvas
+    ctx2d.globalCompositeOperation = 'copy';
+
+    // fill 2d canvas with orange
+    ctx2d.fillStyle = "rgb(255,192,128)";
+    ctx2d.fillRect (0, 0, 40, 40);
+
+    // get the image data
+    var imgData = ctx2d.getImageData(0, 0, 40, 40);
+
+    // check it got cleared.
+    if (!checkPixels(255, 192, 128, 255)) {
+      testFailed("unable to fill 2d context.");
+      return;
+    }
+
+    // draw 3d canvas on top.
+    ctx2d.drawImage(canvas, 0,0, 40, 40);
+
+    // get the image data
+    var imgData = ctx2d.getImageData(0, 0, 40, 40);
+
+    // Check it's the expected color.
+    if (!checkPixels(r3d, g3d, b3d, a3d)) {
+     testFailed("pixels are " + r2d + "," + g2d + "," + b2d + "," + a2d +
+                " expected " + r3d + "," + g3d + "," + b3d + "," + a3d);
+    } else {
+      testPassed("pixels are " + r3d + "," + g3d + "," + b3d + "," + a3d);
+    }
+  }
+
+  checkCanvasContentIs(0, 0, 0, 0);
+  shouldBe('getViewport()', '"0,0,300,150"');
+
+  // Change the display size of the canvas and check
+  // the viewport size does not change.
+  debug("");
+  debug("change display size of canvas and see that viewport does not change");
+  canvas.style.width = "100px";
+  canvas.style.height = "25px";
+  var intervalId;
+  intervalId = window.setInterval(function() {
+    if (canvas.clientWidth == 100 &&
+        canvas.clientHeight == 25) {
+      window.clearInterval(intervalId);
+      shouldBe('getViewport()', '"0,0,300,150"');
+      shouldBe('canvas.width', '300');
+      shouldBe('canvas.height', '150');
+
+      // Change the actual size of the canvas
+      // Check that the viewport does not change.
+      // Check that the clear color does not change.
+      // Check that the color mask does not change.
+      debug("");
+      debug("change the actual size of the canvas and see that the viewport does not change");
+      gl.clearColor(0.25, 0.5, 0.75, 1);
+      gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+      checkCanvasContentIs(64, 128, 192, 255);
+      gl.colorMask(0,0,0,0);
+      glErrorShouldBe(gl, gl.NO_ERROR, "No GL errors before resizing the canvas");
+      canvas.width = 400;
+      canvas.height = 10;
+      err = gl.getError();
+      // Some implementations might lost the context when resizing
+      if (err != gl.CONTEXT_LOST_WEBGL) {
+        shouldBe("err", "gl.NO_ERROR");
+        var v = gl.getParameter(gl.COLOR_CLEAR_VALUE);
+        assertMsg(isAboutEqual(v[0], 0.25) &&
+                  isAboutEqual(v[1], 0.5) &&
+                  isAboutEqual(v[2], 0.75) &&
+                  isAboutEqual(v[3], 1),
+                  "gl.clearColor should not change after canvas resize");
+        v = gl.getParameter(gl.COLOR_WRITEMASK);
+        assertMsg(isAboutEqual(v[0], 0) &&
+                  isAboutEqual(v[1], 0) &&
+                  isAboutEqual(v[2], 0) &&
+                  isAboutEqual(v[3], 0),
+                  "gl.colorMask should not change after canvas resize");
+        shouldBe('getViewport()', '"0,0,300,150"');
+        checkCanvasContentIs(0, 0, 0, 0);
+      }
+
+      debug("");
+      finishTest();
+    }
+   }, 1000/30);
+}
+</script>
+
+</body>
+</html>
diff --git a/LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/canvas-zero-size.html b/LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/canvas-zero-size.html
new file mode 100644 (file)
index 0000000..15bec6f
--- /dev/null
@@ -0,0 +1,65 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+  <head>
+  <meta charset="utf-8">
+    <title>Zero Size Canvas Test</title>
+    <link rel="stylesheet" href="../../resources/js-test-style.css"/>
+    <script src="../../resources/js-test-pre.js"></script>
+    <script src="../resources/webgl-test.js"> </script>
+    <script src="../resources/webgl-test-utils.js"> </script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+description("Tests that a zero size canvas does not fail.");
+var wtu = WebGLTestUtils;
+var canvas = document.createElement('canvas');
+var gl = wtu.create3DContext(canvas);
+canvas.width = 0;
+canvas.height = 0;
+gl.viewport(0, 0, 0, 0);
+var program = wtu.setupTexturedQuad(gl);
+shouldBeTrue("program != null");
+var tex = gl.createTexture();
+gl.bindTexture(gl.TEXTURE_2D, tex);
+var pixel = new Uint8Array([0, 255, 0, 255]);
+gl.texImage2D(
+  gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, pixel);
+wtu.drawQuad(gl);
+
+glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
diff --git a/LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/drawingbuffer-hd-dpi-test.html b/LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/drawingbuffer-hd-dpi-test.html
new file mode 100644 (file)
index 0000000..909de5c
--- /dev/null
@@ -0,0 +1,226 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL DrawingBuffer dimensions on HD-DPI machines test</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script id="vshaderGrid" type="x-shader/x-vertex">
+attribute vec4 a_position;
+void main()
+{
+  gl_Position = a_position;
+}
+</script>
+
+<script id="fshaderGrid" type="x-shader/x-fragment">
+precision mediump float;
+void main()
+{
+  float r = mod(gl_FragCoord.x, 2.0) < 1.0 ? 0.0 : 1.0;
+  float g = mod(gl_FragCoord.y, 2.0) < 1.0 ? 0.0 : 1.0;
+  gl_FragColor = vec4(r, g, 0, 1);
+}
+</script>
+<script>
+"use strict";
+description();
+debug("");
+
+var gl;
+var canvas;
+
+function checkDimensions() {
+  // We expect that for the sizes being testing drawingBufferWidth and drawingBufferHeight
+  // will match canvas.width and canvas.height.
+
+  // We need to test that devicePixelRatio does not effect the backbuffer size of a canvas.
+  shouldBe('gl.drawingBufferWidth', 'canvas.width');
+  shouldBe('gl.drawingBufferHeight', 'canvas.height');
+}
+
+// This uses gl_FragCoord to draw a device pixel relavent pattern.
+// If drawBufferWidth or drawBufferHeight are not in device pixels
+// this test should fail.
+function checkGrid(gl, width, height) {
+  var program = wtu.setupProgram(gl, ["vshaderGrid", "fshaderGrid"], ["a_position"]);
+  wtu.setupUnitQuad(gl);
+  gl.useProgram(program);
+  shouldBe('gl.getError()', 'gl.NO_ERROR');
+
+  wtu.drawQuad(gl);
+
+  var pixels = new Uint8Array(width * height * 4);
+  gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
+
+  var colors = [
+    [ { color: [0,   0, 0, 255], name: "black" },  { color: [255,   0, 0, 255], name: "red"    } ],
+    [ { color: [0, 255, 0, 255], name: "green" },  { color: [255, 255, 0, 255], name: "yellow" } ],
+  ];
+
+  for (var yy = 0; yy < height; ++yy) {
+    for (var xx = 0; xx < width; ++xx) {
+      var info = colors[yy % 2][xx % 2];
+      var color = info.color;
+      var offset = (yy * width + xx) * 4;
+      for (var jj = 0; jj < 4; ++jj) {
+        if (pixels[offset + jj] != color[jj]) {
+          var actual = [pixels[offset], pixels[offset + 1], pixels[offset + 2], pixels[offset + 3]];
+          testFailed("at " + xx + ", " + yy + " expected " + color + "(" + info.name + ") was " + actual);
+          return;
+        }
+      }
+    }
+  }
+  testPassed("grid rendered correctly");
+}
+
+// This passes device coordinate vertices in to make sure gl.viewport is not being mucked with.
+function checkQuad(gl, width, height) {
+  var deviceToClipSpace = function(value, range) {
+    return value / range * 2 - 1;
+  }
+
+  var program = wtu.setupColorQuad(gl);
+
+  // draw a small green square in the top right corner.
+  var deviceX1 = width - 4;
+  var deviceX2 = width;
+  var deviceY1 = height - 4;
+  var deviceY2 = height;
+
+  var clipX1 = deviceToClipSpace(deviceX1, width);
+  var clipX2 = deviceToClipSpace(deviceX2, width);
+  var clipY1 = deviceToClipSpace(deviceY1, height);
+  var clipY2 = deviceToClipSpace(deviceY2, height);
+
+  var vertexObject = gl.createBuffer();
+  gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
+  gl.bufferData(
+      gl.ARRAY_BUFFER,
+      new Float32Array(
+        [ clipX2, clipY2,
+          clipX1, clipY2,
+          clipX1, clipY1,
+          clipX2, clipY2,
+          clipX1, clipY1,
+          clipX2, clipY1]),
+      gl.STATIC_DRAW);
+  gl.enableVertexAttribArray(0);
+  gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
+
+  var green = [0, 255, 0, 255];
+  var black = [0, 0, 0, 0];
+  gl.clearColor(0, 0, 0, 0);
+  gl.clear(gl.COLOR_BUFFER_BIT);
+  wtu.drawUByteColorQuad(gl, [0, 255, 0, 255]);
+
+  var squareWidth = deviceX2 - deviceX1;
+  var squareHeight = deviceY2 - deviceY1;
+
+  // check the square.
+  wtu.checkCanvasRect(gl, deviceX1, deviceY1, squareWidth, squareHeight, green, "should be green");
+  // check outside the square.
+  wtu.checkCanvasRect(gl, 0, 0, width, height - squareHeight, black, "should be black");
+  wtu.checkCanvasRect(gl, 0, height - squareHeight, width - squareWidth, squareHeight, black, "should be black");
+}
+
+
+function test(desiredWidth, desiredHeight) {
+  debug("");
+  debug("testing canvas width = " + desiredWidth + ", height = " + desiredHeight);
+
+  // Make a fresh canvas.
+  canvas = document.createElement("canvas");
+  canvas.width = desiredWidth;
+  canvas.height = desiredHeight;
+
+  // This 'gl' must be global for shouldBe to work.
+  gl = wtu.create3DContext(canvas, {antialias: false});
+  if (!gl) {
+    testFailed("context does not exist");
+  } else {
+    testPassed("context exists");
+
+    // Check the dimensions are correct.
+    checkDimensions();
+
+    // Draw a pixel grid using a shader that draws in device coordinates
+    checkGrid(gl, desiredWidth, desiredHeight);
+
+    // Draw a quad in the top right corner.
+    checkQuad(gl, desiredWidth, desiredHeight);
+
+    shouldBe('gl.getError()', 'gl.NO_ERROR');
+
+    debug("");
+    debug("testing resizing canvas to width = " + desiredWidth + ", height = " + desiredHeight);
+
+    var oldViewport = gl.getParameter(gl.VIEWPORT);
+
+    // flip width and height
+    canvas.width = desiredHeight;
+    canvas.height = desiredWidth;
+
+    // fix the viewport
+    gl.viewport(0, 0, desiredHeight, desiredWidth);
+
+    // Check the dimensions are correct.
+    checkDimensions();
+
+    // Draw a pixel grid using a shader that draws in device coordinates
+    checkGrid(gl, desiredHeight, desiredWidth);
+
+    // Draw a quad in the top right corner.
+    checkQuad(gl, desiredHeight, desiredWidth);
+
+    shouldBe('gl.getError()', 'gl.NO_ERROR');
+  }
+}
+
+var wtu = WebGLTestUtils;
+
+// test a few sizes
+test(32, 16);
+test(128, 64);
+test(256, 512);
+
+debug("")
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/drawingbuffer-static-canvas-test.html b/LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/drawingbuffer-static-canvas-test.html
new file mode 100644 (file)
index 0000000..18bca09
--- /dev/null
@@ -0,0 +1,168 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Canvas Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="canvas" width="50" height="50"> </canvas>
+
+<script id="vshader" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+void main()
+{
+  gl_Position = vPosition;
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+void main()
+{
+  gl_FragColor = vec4(1.0,0.0,0.0,1.0);
+}
+</script>
+
+<script>
+"use strict";
+function fail(x,y, buf, shouldBe)
+{
+  var i = (y*50+x) * 4;
+  var reason = "pixel at ("+x+","+y+") is ("+buf[i]+","+buf[i+1]+","+buf[i+2]+","+buf[i+3]+"), should be "+shouldBe;
+  testFailed(reason);
+}
+
+function pass()
+{
+  testPassed("drawing is correct");
+}
+
+function drawTriangleTest(gl)
+{
+  gl.viewport(0, 0, 50, 50);
+  var vertexObject = gl.createBuffer();
+  gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
+  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), gl.STATIC_DRAW);
+  gl.enableVertexAttribArray(0);
+  gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
+
+  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+  gl.drawArrays(gl.TRIANGLES, 0, 3);
+
+  var buf = new Uint8Array(50 * 50 * 4);
+  gl.readPixels(0, 0, 50, 50, gl.RGBA, gl.UNSIGNED_BYTE, buf);
+
+  // Test several locations
+  // First line should be all black
+  for (var i = 0; i < 50; ++i) {
+    if (buf[i*4] != 0 || buf[i*4+1] != 0 || buf[i*4+2] != 0 || buf[i*4+3] != 255) {
+      fail(i, 0, buf, "(0,0,0,255)");
+      return;
+    }
+  }
+  // Line 15 should be red for at least 10 red pixels starting 20 pixels in
+  var offset = (15*50+20) * 4;
+  for (var i = 0; i < 10; ++i) {
+    if (buf[offset+i*4] != 255 || buf[offset+i*4+1] != 0 || buf[offset+i*4+2] != 0 || buf[offset+i*4+3] != 255) {
+      fail(20 + i, 15, buf, "(255,0,0,255)");
+      return;
+    }
+  }
+  // Last line should be all black
+  offset = (49*50) * 4;
+  for (var i = 0; i < 50; ++i) {
+    if (buf[offset+i*4] != 0 || buf[offset+i*4+1] != 0 || buf[offset+i*4+2] != 0 || buf[offset+i*4+3] != 255) {
+      fail(i, 49, buf, "(0,0,0,255)");
+      return;
+    }
+  }
+}
+
+description("This test ensures WebGL implementations correctly implement drawingbufferWidth/Height with compositing.");
+
+debug("");
+
+var wtu = WebGLTestUtils;
+var err;
+var maxSize;
+var gl =  wtu.create3DContext("canvas");
+if (!gl) {
+  testFailed("context does not exist");
+} else {
+  testPassed("context exists");
+
+  var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
+  shouldBeNonNull("program");
+  gl.enable(gl.DEPTH_TEST);
+  gl.clearColor(0, 0, 0, 1);
+  shouldBe('gl.getError()', 'gl.NO_ERROR');
+
+  debug("");
+  debug("Checking drawingBufferWidth/drawingBufferHeight");
+
+  // Check that a canvas with no width or height is 300x150 pixels
+  shouldBe('gl.drawingBufferWidth', 'gl.canvas.width');
+  shouldBe('gl.drawingBufferHeight', 'gl.canvas.height');
+
+  // Check that changing the canvas size to something too large falls back to reasonable values.
+  maxSize = gl.getParameter(gl.MAX_VIEWPORT_DIMS);
+  shouldBeTrue('maxSize[0] > 0');
+  shouldBeTrue('maxSize[1] > 0');
+
+  // debug("MAX_VIEWPORT_DIMS = " + maxSize[0] + "x" + maxSize[1]);
+  gl.canvas.width = maxSize[0] * 4;
+  gl.canvas.height = maxSize[1] * 4;
+  shouldBeTrue('gl.drawingBufferWidth > 0');
+  shouldBeTrue('gl.drawingBufferHeight > 0');
+  shouldBeTrue('gl.drawingBufferWidth <= maxSize[0]');
+  shouldBeTrue('gl.drawingBufferHeight <= maxSize[1]');
+  shouldBe('gl.getError()', 'gl.NO_ERROR');
+
+  debug("");
+  debug("Checking scaling up then back down to 50/50, drawing still works.");
+  gl.canvas.width = 50;
+  gl.canvas.height = 50;
+  shouldBeTrue('gl.drawingBufferWidth == 50');
+  shouldBeTrue('gl.drawingBufferHeight == 50');
+  shouldBe('gl.getError()', 'gl.NO_ERROR');
+  drawTriangleTest(gl);
+  shouldBe('gl.getError()', 'gl.NO_ERROR');
+}
+debug("")
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/framebuffer-bindings-unaffected-on-resize.html b/LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/framebuffer-bindings-unaffected-on-resize.html
new file mode 100644 (file)
index 0000000..735f957
--- /dev/null
@@ -0,0 +1,108 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Verifies that GL framebuffer bindings do not change when canvas is resized</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<canvas id="example" width="4" height="4"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+description("Verifies that GL framebuffer bindings do not change when canvas is resized");
+
+initTestingHarnessWaitUntilDone();
+
+var err;
+var wtu = WebGLTestUtils;
+var canvas = document.getElementById("example");
+var gl = wtu.create3DContext(canvas);
+var green = [0, 255, 0, 255];
+var blue = [0, 0, 255, 255];
+var fboSize = 2;
+shouldBeTrue("fboSize < canvas.width");
+var fbo = gl.createFramebuffer();
+gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
+var fboTex = gl.createTexture();
+gl.activeTexture(gl.TEXTURE1);
+gl.bindTexture(gl.TEXTURE_2D, fboTex);
+gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, fboTex, 0);
+gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, fboSize, fboSize, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
+
+function checkFBO(color, msg) {
+  wtu.checkCanvasRect(gl, 0, 0, fboSize, fboSize, color, msg);
+  wtu.checkCanvasRect(gl, fboSize, fboSize, fboSize, fboSize, [0, 0, 0, 0], "area outside fbo should be transparent black");
+}
+
+// The FBO is 2x2 and it's bound so clearing should clear a 2x2 area
+// and calling read pixels should read the clear color in that 2x2 area
+// and 0,0,0,0 outside that area.
+//
+// If the FBO is no longer bound because of a WebGL implementation error
+// then likely the clear will clear the backbuffer and reading outside
+// the 2x2 area will not be 0,0,0,0
+
+function test() {
+  gl.clearColor(0, 0, 1, 1);
+  gl.clear(gl.COLOR_BUFFER_BIT);
+  checkFBO(blue, "should be blue");
+  gl.clearColor(0, 1, 0, 1);
+  gl.clear(gl.COLOR_BUFFER_BIT);
+  checkFBO(green, "should be green");
+}
+
+debug("test before resizing canvas");
+test();
+debug("test after resizing canvas");
+canvas.width = 8;
+test();
+debug("test after resizing canvas and waiting for compositing");
+canvas.width = 16;
+wtu.waitForComposite(gl, function() {
+  test();
+  finishTest();
+  glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
+});
+
+var successfullyParsed = true;
+</script>
+</body>
+</html>
+
diff --git a/LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/texture-bindings-unaffected-on-resize.html b/LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/texture-bindings-unaffected-on-resize.html
new file mode 100644 (file)
index 0000000..dd79c94
--- /dev/null
@@ -0,0 +1,90 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<canvas id="example" width="4" height="4"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+description('Verifies that GL texture bindings do not change when canvas is resized');
+
+initTestingHarnessWaitUntilDone();
+
+var err;
+var wtu = WebGLTestUtils;
+var canvas = document.getElementById("example");
+var gl = wtu.create3DContext(canvas);
+var program = wtu.setupTexturedQuad(gl);
+
+var green = [0, 255, 0, 255];
+var blue = [0, 0, 255, 255];
+var tex0 = gl.createTexture();
+wtu.fillTexture(gl, tex0, 1, 1, blue, 0);
+gl.activeTexture(gl.TEXTURE1)
+var tex1 = gl.createTexture();
+wtu.fillTexture(gl, tex1, 1, 1, green, 0);
+
+var loc = gl.getUniformLocation(program, "tex");
+
+function test() {
+  gl.viewport(0, 0, canvas.width, canvas.height);
+  gl.uniform1i(loc, 0);
+  wtu.drawQuad(gl);
+  wtu.checkCanvas(gl, blue, "should be blue");
+  gl.uniform1i(loc, 1);
+  wtu.drawQuad(gl);
+  wtu.checkCanvas(gl, green, "should be green");
+}
+
+debug("test before resizing canvas");
+test();
+debug("test after resizing canvas");
+canvas.width = 8;
+test();
+debug("test after resizing canvas and waiting for compositing");
+canvas.width = 16;
+wtu.waitForComposite(gl, function() {
+  test();
+  finishTest();
+  glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
+});
+
+var successfullyParsed = true;
+</script>
+</body>
+</html>
+
diff --git a/LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/viewport-unchanged-upon-resize.html b/LayoutTests/webgl/resources/webgl_test_files/conformance/canvas/viewport-unchanged-upon-resize.html
new file mode 100644 (file)
index 0000000..bce872d
--- /dev/null
@@ -0,0 +1,114 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script id="vshader" type="x-shader/x-vertex">
+attribute vec3 g_Position;
+
+void main()
+{
+    gl_Position = vec4(g_Position.x, g_Position.y, g_Position.z, 1.0);
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+void main()
+{
+    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+</script>
+
+</head>
+<body>
+<canvas id="example" width="4" height="4"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+description('Verifies that GL viewport does not change when canvas is resized');
+
+var err;
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["g_Position"]);
+
+var vertices = new Float32Array([
+     1.0,  1.0, 0.0,
+    -1.0,  1.0, 0.0,
+    -1.0, -1.0, 0.0,
+     1.0,  1.0, 0.0,
+    -1.0, -1.0, 0.0,
+     1.0, -1.0, 0.0]);
+var vbo = gl.createBuffer();
+gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
+gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
+
+gl.enableVertexAttribArray(0);
+gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
+
+// Clear and set up
+gl.clearColor(0, 0, 1, 1);
+gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+gl.useProgram(program);
+// Draw the triangle pair to the frame buffer
+gl.drawArrays(gl.TRIANGLES, 0, 6);
+
+// Ensure that the frame buffer is red at the sampled pixel
+wtu.checkCanvasRect(gl, 2, 2, 1, 1, [255, 0, 0, 255]);
+
+// Now resize the canvas
+glErrorShouldBe(gl, gl.NO_ERROR, "No GL errors before resizing the canvas");
+var canvas = gl.canvas;
+canvas.width = 8;
+canvas.height = 8;
+err = gl.getError();
+// Some implementations might lost the context when resizing
+if (err == gl.CONTEXT_LOST_WEBGL) {
+  testPassed("canvas lost context on resize");
+} else {
+  shouldBe("err", "gl.NO_ERROR");
+  // Do another render
+  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+  gl.drawArrays(gl.TRIANGLES, 0, 6);
+  // This time, because we did not change the viewport, it should
+  // still be (0, 0, 4, 4), so only the lower-left quadrant should
+  // have been filled.
+  wtu.checkCanvasRect(gl, 6, 6, 1, 1, [0, 0, 255, 255]);
+}
+
+var successfullyParsed = true;
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
+