browser/devtools/shadereditor/test/browser_webgl-actor-test-16.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 program actors are invalidated from the cache when a window is
michael@0 6 * removed from the bfcache.
michael@0 7 */
michael@0 8
michael@0 9 function ifWebGLSupported() {
michael@0 10 let [target, debuggee, front] = yield initBackend(SIMPLE_CANVAS_URL);
michael@0 11 front.setup({ reload: false });
michael@0 12
michael@0 13 // 0. Perform the initial reload.
michael@0 14
michael@0 15 reload(target);
michael@0 16 let firstProgram = yield once(front, "program-linked");
michael@0 17 let programs = yield front.getPrograms();
michael@0 18 is(programs.length, 1,
michael@0 19 "The first program should be returned by a call to getPrograms().");
michael@0 20 is(programs[0], firstProgram,
michael@0 21 "The first programs was correctly retrieved from the cache.");
michael@0 22
michael@0 23 // 1. Perform a simple navigation.
michael@0 24
michael@0 25 navigate(target, MULTIPLE_CONTEXTS_URL);
michael@0 26 let [secondProgram, thirdProgram] = yield getPrograms(front, 2);
michael@0 27 let programs = yield front.getPrograms();
michael@0 28 is(programs.length, 2,
michael@0 29 "The second and third programs should be returned by a call to getPrograms().");
michael@0 30 is(programs[0], secondProgram,
michael@0 31 "The second programs was correctly retrieved from the cache.");
michael@0 32 is(programs[1], thirdProgram,
michael@0 33 "The third programs was correctly retrieved from the cache.");
michael@0 34
michael@0 35 // 2. Perform a bfcache navigation.
michael@0 36
michael@0 37 yield navigateInHistory(target, "back");
michael@0 38 let globalDestroyed = observe("inner-window-destroyed");
michael@0 39 let globalCreated = observe("content-document-global-created");
michael@0 40 reload(target);
michael@0 41
michael@0 42 yield globalDestroyed;
michael@0 43 let programs = yield front.getPrograms();
michael@0 44 is(programs.length, 0,
michael@0 45 "There should be no cached program actors yet.");
michael@0 46
michael@0 47 yield globalCreated;
michael@0 48 let programs = yield front.getPrograms();
michael@0 49 is(programs.length, 1,
michael@0 50 "There should be 1 cached program actor now.");
michael@0 51
michael@0 52 yield checkHighlightingInTheFirstPage(programs[0]);
michael@0 53 ok(true, "The cached programs behave correctly after navigating back and reloading.");
michael@0 54
michael@0 55 // 3. Perform a bfcache navigation and a page reload.
michael@0 56
michael@0 57 yield navigateInHistory(target, "forward");
michael@0 58 let globalDestroyed = observe("inner-window-destroyed");
michael@0 59 let globalCreated = observe("content-document-global-created");
michael@0 60 reload(target);
michael@0 61
michael@0 62 yield globalDestroyed;
michael@0 63 let programs = yield front.getPrograms();
michael@0 64 is(programs.length, 0,
michael@0 65 "There should be no cached program actors yet.");
michael@0 66
michael@0 67 yield getPrograms(front, 2);
michael@0 68 yield globalCreated;
michael@0 69 let programs = yield front.getPrograms();
michael@0 70 is(programs.length, 2,
michael@0 71 "There should be 2 cached program actors now.");
michael@0 72
michael@0 73 yield checkHighlightingInTheSecondPage(programs[0], programs[1]);
michael@0 74 ok(true, "The cached programs behave correctly after navigating forward and reloading.");
michael@0 75
michael@0 76 yield removeTab(target.tab);
michael@0 77 finish();
michael@0 78
michael@0 79 function checkHighlightingInTheFirstPage(programActor) {
michael@0 80 return Task.spawn(function() {
michael@0 81 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
michael@0 82 yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
michael@0 83 ok(true, "The corner pixel colors are correct before highlighting.");
michael@0 84
michael@0 85 yield programActor.highlight([0, 1, 0, 1]);
michael@0 86 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true);
michael@0 87 yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
michael@0 88 ok(true, "The corner pixel colors are correct after highlighting.");
michael@0 89
michael@0 90 yield programActor.unhighlight();
michael@0 91 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
michael@0 92 yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
michael@0 93 ok(true, "The corner pixel colors are correct after unhighlighting.");
michael@0 94 });
michael@0 95 }
michael@0 96
michael@0 97 function checkHighlightingInTheSecondPage(firstProgramActor, secondProgramActor) {
michael@0 98 return Task.spawn(function() {
michael@0 99 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
michael@0 100 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 101 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
michael@0 102 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 103 ok(true, "The two canvases are correctly drawn before highlighting.");
michael@0 104
michael@0 105 yield firstProgramActor.highlight([1, 0, 0, 1]);
michael@0 106 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1");
michael@0 107 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 108 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1");
michael@0 109 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 110 ok(true, "The first canvas was correctly filled after highlighting.");
michael@0 111
michael@0 112 yield secondProgramActor.highlight([0, 1, 0, 1]);
michael@0 113 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1");
michael@0 114 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 0, a: 255 }, true, "#canvas2");
michael@0 115 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1");
michael@0 116 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 0, a: 255 }, true, "#canvas2");
michael@0 117 ok(true, "The second canvas was correctly filled after highlighting.");
michael@0 118
michael@0 119 yield firstProgramActor.unhighlight();
michael@0 120 yield secondProgramActor.unhighlight();
michael@0 121 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
michael@0 122 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 123 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
michael@0 124 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 125 ok(true, "The two canvases were correctly filled after unhighlighting.");
michael@0 126 });
michael@0 127 }
michael@0 128 }

mercurial