Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: third_party/webgl/conformance-suites/1.0.0/conformance/origin-clean-conformance.html

Issue 9360034: Remove everthing except conformance tests in the deps/third_party/webgl (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!--
2 Copyright (c) 2009 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
5 -->
6 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
7 "http://www.w3.org/TR/html4/loose.dtd">
8 <html>
9 <head>
10 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
11 <title>WebGL Origin Restrictions Conformance Tests</title>
12 <link rel="stylesheet" href="../resources/js-test-style.css"/>
13 <script src="../resources/desktop-gl-constants.js" type="text/javascript"></scri pt>
14 <script src="../resources/js-test-pre.js"></script>
15 <script src="resources/webgl-test.js"></script>
16 <script>
17 // This function returns the last 2 words of the domain of a URL
18 // This is probably not the correct check but it will do for now.
19 function getBaseDomain(str) {
20 str = str.replace("\\", "/");
21 var pos = str.indexOf("://");
22 if (pos >= 0) {
23 str = str.substr(pos + 3);
24 }
25 var parts = str.split('/');
26 var domain = parts[0].match(/\w+\.\w+$/);
27 return domain || '';
28 }
29
30 // Checks if function throws an exception.
31 function causedException(func) {
32 var hadException = false;
33 try {
34 func();
35 } catch(e) {
36 //debug(e);
37 hadException = true;
38 }
39 //debug ("hadException: " + hadException);
40 return hadException;
41 }
42
43 window.onload = function() {
44 description("This test ensures WebGL implementations follow proper origin rest rictions.");
45 debug("");
46 var img = document.getElementById("img");
47 imgDomain = getBaseDomain(img.src);
48 pageDomain = getBaseDomain(window.location.toString());
49 assertMsg(imgDomain != pageDomain,
50 "img domain (" + imgDomain + ") and page domain (" + pageDomain + ") are not the same.");
51
52 function makeReadPixels(gl) {
53 return function() {
54 var buf = new Uint8Array(4);
55 gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf);
56 };
57 }
58
59 function makeToDataURL(canvas) {
60 return function() {
61 var data = canvas.toDataURL();
62 }
63 }
64
65 debug("");
66 debug("check that copying an img from another origin clears the origin-clean f lag.");
67 var canvas1 = document.getElementById("canvas1");
68 var gl1 = create3DContext(canvas1);
69 assertMsg(!causedException(makeReadPixels(gl1)),
70 "should not throw exception by readPixels for origin clean canvas.") ;
71 assertMsg(!causedException(makeToDataURL(canvas1)),
72 "should not throw exception by toDataURL for origin clean canvas.");
73
74 var tex = gl1.createTexture();
75 gl1.bindTexture(gl1.TEXTURE_2D, tex);
76 gl1.texImage2D(gl1.TEXTURE_2D, 0, gl1.RGBA, gl1.RGBA, gl1.UNSIGNED_BYTE, img);
77
78 assertMsg(causedException(makeReadPixels(gl1)),
79 "should throw exception by readPixels for NON origin clean canvas.") ;
80 assertMsg(causedException(makeToDataURL(canvas1)),
81 "should throw exception by toDataURL for NON origin clean canvas.");
82
83 debug("");
84 debug("check that copying from 1 unclean 3d canvas to another clears the origi n-clean flag on the second canvas.");
85 var canvas2 = document.getElementById("canvas2");
86 var gl2 = create3DContext(canvas2);
87
88 assertMsg(!causedException(makeReadPixels(gl2)),
89 "should not throw exception by readPixels for origin clean canvas.") ;
90 assertMsg(!causedException(makeToDataURL(canvas2)),
91 "should not throw exception by toDataURL for origin clean canvas.");
92
93 var tex = gl2.createTexture();
94 gl2.bindTexture(gl2.TEXTURE_2D, tex);
95 gl2.texImage2D(
96 gl2.TEXTURE_2D, 0, gl2.RGBA, gl2.RGBA, gl2.UNSIGNED_BYTE, canvas1);
97
98 assertMsg(causedException(makeReadPixels(gl2)),
99 "should throw exception by readPixels for NON origin clean canvas.") ;
100 assertMsg(causedException(makeToDataURL(canvas2)),
101 "should throw exception by toDataURL for NON origin clean canvas.");
102
103 debug("");
104 debug("check that copying from 1 unclean 3d canvas to a 2d canvas clears the o rigin-clean flag on the 2d canvas.");
105 var canvas3 = document.getElementById("canvas3");
106 var ctx2d = canvas3.getContext("2d");
107 assertMsg(!causedException(makeToDataURL(canvas3)),
108 "should not throw exception by toDataURL for origin clean canvas.");
109 ctx2d.drawImage(canvas2, 0, 0);
110 assertMsg(causedException(makeToDataURL(canvas3)),
111 "should throw exception by toDataURL for NON origin clean canvas.");
112
113
114 // TODO: Should check video?
115
116 debug("");
117 successfullyParsed = true;
118 shouldBeTrue("successfullyParsed");
119 debug('<br /><span class="pass">TEST COMPLETE</span>');
120 notifyFinishedToHarness();
121 }
122 </script>
123 </head>
124 <body>
125 <div id="description"></div>
126 <div id="console"></div>
127 <canvas id="canvas1"></canvas>
128 <canvas id="canvas2"></canvas>
129 <canvas id="canvas3"></canvas>
130 <img id="img" src="http://www.opengl.org/img/opengl_logo.jpg" style="display:non e;"/>
131 </body>
132 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698