|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests if multiple WebGL contexts are correctly handled. |
|
6 */ |
|
7 |
|
8 function ifWebGLSupported() { |
|
9 let [target, debuggee, front] = yield initBackend(MULTIPLE_CONTEXTS_URL); |
|
10 front.setup({ reload: true }); |
|
11 |
|
12 let [firstProgramActor, secondProgramActor] = yield getPrograms(front, 2); |
|
13 |
|
14 isnot(firstProgramActor, secondProgramActor, |
|
15 "Two distinct program actors were recevide from two separate contexts."); |
|
16 |
|
17 let firstVertexShader = yield firstProgramActor.getVertexShader(); |
|
18 let firstFragmentShader = yield firstProgramActor.getFragmentShader(); |
|
19 let secondVertexShader = yield secondProgramActor.getVertexShader(); |
|
20 let secondFragmentShader = yield secondProgramActor.getFragmentShader(); |
|
21 |
|
22 isnot(firstVertexShader, secondVertexShader, |
|
23 "The two programs should have distinct vertex shaders."); |
|
24 isnot(firstFragmentShader, secondFragmentShader, |
|
25 "The two programs should have distinct fragment shaders."); |
|
26 |
|
27 let firstVertSource = yield firstVertexShader.getText(); |
|
28 let firstFragSource = yield firstFragmentShader.getText(); |
|
29 let secondVertSource = yield secondVertexShader.getText(); |
|
30 let secondFragSource = yield secondFragmentShader.getText(); |
|
31 |
|
32 is(firstVertSource, secondVertSource, |
|
33 "The vertex shaders should have identical sources."); |
|
34 is(firstFragSource, secondFragSource, |
|
35 "The vertex shaders should have identical sources."); |
|
36 |
|
37 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
38 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
39 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
40 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
41 ok(true, "The two canvases are correctly drawn."); |
|
42 |
|
43 yield firstProgramActor.highlight([1, 0, 0, 1]); |
|
44 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
45 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
46 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
47 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
48 ok(true, "The first canvas was correctly filled after highlighting."); |
|
49 |
|
50 yield secondProgramActor.highlight([0, 1, 0, 1]); |
|
51 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
52 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 0, a: 255 }, true, "#canvas2"); |
|
53 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
54 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 0, a: 255 }, true, "#canvas2"); |
|
55 ok(true, "The second canvas was correctly filled after highlighting."); |
|
56 |
|
57 yield firstProgramActor.unhighlight(); |
|
58 yield secondProgramActor.unhighlight(); |
|
59 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
60 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
61 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
62 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
63 ok(true, "The two canvases were correctly filled after unhighlighting."); |
|
64 |
|
65 yield removeTab(target.tab); |
|
66 finish(); |
|
67 } |