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