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 blackboxing a program works properly. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | function ifWebGLSupported() { |
michael@0 | 9 | let [target, debuggee, panel] = yield initShaderEditor(MULTIPLE_CONTEXTS_URL); |
michael@0 | 10 | let { gFront, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin; |
michael@0 | 11 | |
michael@0 | 12 | once(panel.panelWin, EVENTS.SHADER_COMPILED).then(() => { |
michael@0 | 13 | ok(false, "No shaders should be publicly compiled during this test."); |
michael@0 | 14 | }); |
michael@0 | 15 | |
michael@0 | 16 | reload(target); |
michael@0 | 17 | let [[firstProgramActor, secondProgramActor]] = yield promise.all([ |
michael@0 | 18 | getPrograms(gFront, 2), |
michael@0 | 19 | once(panel.panelWin, EVENTS.SOURCES_SHOWN) |
michael@0 | 20 | ]); |
michael@0 | 21 | |
michael@0 | 22 | let vsEditor = yield ShadersEditorsView._getEditor("vs"); |
michael@0 | 23 | let fsEditor = yield ShadersEditorsView._getEditor("fs"); |
michael@0 | 24 | |
michael@0 | 25 | vsEditor.once("change", () => { |
michael@0 | 26 | ok(false, "The vertex shader source was unexpectedly changed."); |
michael@0 | 27 | }); |
michael@0 | 28 | fsEditor.once("change", () => { |
michael@0 | 29 | ok(false, "The fragment shader source was unexpectedly changed."); |
michael@0 | 30 | }); |
michael@0 | 31 | once(panel.panelWin, EVENTS.SOURCES_SHOWN).then(() => { |
michael@0 | 32 | ok(false, "No sources should be changed form this point onward."); |
michael@0 | 33 | }); |
michael@0 | 34 | |
michael@0 | 35 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 36 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
michael@0 | 37 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 38 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
michael@0 | 39 | |
michael@0 | 40 | ok(!ShadersListView.selectedAttachment.isBlackBoxed, |
michael@0 | 41 | "The first program should not be blackboxed yet."); |
michael@0 | 42 | is(getBlackBoxCheckbox(panel, 0).checked, true, |
michael@0 | 43 | "The first blackbox checkbox should be initially checked."); |
michael@0 | 44 | ok(!ShadersListView.attachments[1].isBlackBoxed, |
michael@0 | 45 | "The second program should not be blackboxed yet."); |
michael@0 | 46 | is(getBlackBoxCheckbox(panel, 1).checked, true, |
michael@0 | 47 | "The second blackbox checkbox should be initially checked."); |
michael@0 | 48 | |
michael@0 | 49 | getBlackBoxCheckbox(panel, 0).click(); |
michael@0 | 50 | |
michael@0 | 51 | ok(ShadersListView.selectedAttachment.isBlackBoxed, |
michael@0 | 52 | "The first program should now be blackboxed."); |
michael@0 | 53 | is(getBlackBoxCheckbox(panel, 0).checked, false, |
michael@0 | 54 | "The first blackbox checkbox should now be unchecked."); |
michael@0 | 55 | ok(!ShadersListView.attachments[1].isBlackBoxed, |
michael@0 | 56 | "The second program should still not be blackboxed."); |
michael@0 | 57 | is(getBlackBoxCheckbox(panel, 1).checked, true, |
michael@0 | 58 | "The second blackbox checkbox should still be checked."); |
michael@0 | 59 | |
michael@0 | 60 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 61 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
michael@0 | 62 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 63 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
michael@0 | 64 | ok(true, "The first program was correctly blackboxed."); |
michael@0 | 65 | |
michael@0 | 66 | getBlackBoxCheckbox(panel, 1).click(); |
michael@0 | 67 | |
michael@0 | 68 | ok(ShadersListView.selectedAttachment.isBlackBoxed, |
michael@0 | 69 | "The first program should still be blackboxed."); |
michael@0 | 70 | is(getBlackBoxCheckbox(panel, 0).checked, false, |
michael@0 | 71 | "The first blackbox checkbox should still be unchecked."); |
michael@0 | 72 | ok(ShadersListView.attachments[1].isBlackBoxed, |
michael@0 | 73 | "The second program should now be blackboxed."); |
michael@0 | 74 | is(getBlackBoxCheckbox(panel, 1).checked, false, |
michael@0 | 75 | "The second blackbox checkbox should now be unchecked."); |
michael@0 | 76 | |
michael@0 | 77 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 78 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2"); |
michael@0 | 79 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 80 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2"); |
michael@0 | 81 | ok(true, "The second program was correctly blackboxed."); |
michael@0 | 82 | |
michael@0 | 83 | ShadersListView._onProgramMouseEnter({ target: getItemLabel(panel, 0) }); |
michael@0 | 84 | |
michael@0 | 85 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 86 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2"); |
michael@0 | 87 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 88 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2"); |
michael@0 | 89 | ok(true, "Highlighting shouldn't work while blackboxed (1)."); |
michael@0 | 90 | |
michael@0 | 91 | ShadersListView._onProgramMouseLeave({ target: getItemLabel(panel, 0) }); |
michael@0 | 92 | ShadersListView._onProgramMouseEnter({ target: getItemLabel(panel, 1) }); |
michael@0 | 93 | |
michael@0 | 94 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 95 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2"); |
michael@0 | 96 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 97 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2"); |
michael@0 | 98 | ok(true, "Highlighting shouldn't work while blackboxed (2)."); |
michael@0 | 99 | |
michael@0 | 100 | ShadersListView._onProgramMouseLeave({ target: getItemLabel(panel, 1) }); |
michael@0 | 101 | |
michael@0 | 102 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 103 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2"); |
michael@0 | 104 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 105 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2"); |
michael@0 | 106 | ok(true, "Highlighting shouldn't work while blackboxed (3)."); |
michael@0 | 107 | |
michael@0 | 108 | getBlackBoxCheckbox(panel, 0).click(); |
michael@0 | 109 | getBlackBoxCheckbox(panel, 1).click(); |
michael@0 | 110 | |
michael@0 | 111 | ok(!ShadersListView.selectedAttachment.isBlackBoxed, |
michael@0 | 112 | "The first program should now be unblackboxed."); |
michael@0 | 113 | is(getBlackBoxCheckbox(panel, 0).checked, true, |
michael@0 | 114 | "The first blackbox checkbox should now be rechecked."); |
michael@0 | 115 | ok(!ShadersListView.attachments[1].isBlackBoxed, |
michael@0 | 116 | "The second program should now be unblackboxed."); |
michael@0 | 117 | is(getBlackBoxCheckbox(panel, 1).checked, true, |
michael@0 | 118 | "The second blackbox checkbox should now be rechecked."); |
michael@0 | 119 | |
michael@0 | 120 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 121 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
michael@0 | 122 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 123 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
michael@0 | 124 | ok(true, "The two programs were correctly unblackboxed."); |
michael@0 | 125 | |
michael@0 | 126 | ShadersListView._onProgramMouseEnter({ target: getItemLabel(panel, 0) }); |
michael@0 | 127 | |
michael@0 | 128 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 129 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
michael@0 | 130 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 131 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
michael@0 | 132 | ok(true, "The first program was correctly highlighted."); |
michael@0 | 133 | |
michael@0 | 134 | ShadersListView._onProgramMouseLeave({ target: getItemLabel(panel, 0) }); |
michael@0 | 135 | ShadersListView._onProgramMouseEnter({ target: getItemLabel(panel, 1) }); |
michael@0 | 136 | |
michael@0 | 137 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 138 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 64, a: 255 }, true, "#canvas2"); |
michael@0 | 139 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 140 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 64, a: 255 }, true, "#canvas2"); |
michael@0 | 141 | ok(true, "The second program was correctly highlighted."); |
michael@0 | 142 | |
michael@0 | 143 | ShadersListView._onProgramMouseLeave({ target: getItemLabel(panel, 1) }); |
michael@0 | 144 | |
michael@0 | 145 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 146 | yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
michael@0 | 147 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
michael@0 | 148 | yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
michael@0 | 149 | ok(true, "The two programs were correctly unhighlighted."); |
michael@0 | 150 | |
michael@0 | 151 | yield teardown(panel); |
michael@0 | 152 | finish(); |
michael@0 | 153 | } |
michael@0 | 154 | |
michael@0 | 155 | function getItemLabel(aPanel, aIndex) { |
michael@0 | 156 | return aPanel.panelWin.document.querySelectorAll( |
michael@0 | 157 | ".side-menu-widget-item-contents")[aIndex]; |
michael@0 | 158 | } |
michael@0 | 159 | |
michael@0 | 160 | function getBlackBoxCheckbox(aPanel, aIndex) { |
michael@0 | 161 | return aPanel.panelWin.document.querySelectorAll( |
michael@0 | 162 | ".side-menu-widget-item-checkbox")[aIndex]; |
michael@0 | 163 | } |
michael@0 | 164 | |
michael@0 | 165 | function once(aTarget, aEvent) { |
michael@0 | 166 | let deferred = promise.defer(); |
michael@0 | 167 | aTarget.once(aEvent, deferred.resolve); |
michael@0 | 168 | return deferred.promise; |
michael@0 | 169 | } |