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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/shadereditor/test/browser_webgl-actor-test-16.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,128 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Tests if program actors are invalidated from the cache when a window is
     1.9 + * removed from the bfcache.
    1.10 + */
    1.11 +
    1.12 +function ifWebGLSupported() {
    1.13 +  let [target, debuggee, front] = yield initBackend(SIMPLE_CANVAS_URL);
    1.14 +  front.setup({ reload: false });
    1.15 +
    1.16 +  // 0. Perform the initial reload.
    1.17 +
    1.18 +  reload(target);
    1.19 +  let firstProgram = yield once(front, "program-linked");
    1.20 +  let programs = yield front.getPrograms();
    1.21 +  is(programs.length, 1,
    1.22 +    "The first program should be returned by a call to getPrograms().");
    1.23 +  is(programs[0], firstProgram,
    1.24 +    "The first programs was correctly retrieved from the cache.");
    1.25 +
    1.26 +  // 1. Perform a simple navigation.
    1.27 +
    1.28 +  navigate(target, MULTIPLE_CONTEXTS_URL);
    1.29 +  let [secondProgram, thirdProgram] = yield getPrograms(front, 2);
    1.30 +  let programs = yield front.getPrograms();
    1.31 +  is(programs.length, 2,
    1.32 +    "The second and third programs should be returned by a call to getPrograms().");
    1.33 +  is(programs[0], secondProgram,
    1.34 +    "The second programs was correctly retrieved from the cache.");
    1.35 +  is(programs[1], thirdProgram,
    1.36 +    "The third programs was correctly retrieved from the cache.");
    1.37 +
    1.38 +  // 2. Perform a bfcache navigation.
    1.39 +
    1.40 +  yield navigateInHistory(target, "back");
    1.41 +  let globalDestroyed = observe("inner-window-destroyed");
    1.42 +  let globalCreated = observe("content-document-global-created");
    1.43 +  reload(target);
    1.44 +
    1.45 +  yield globalDestroyed;
    1.46 +  let programs = yield front.getPrograms();
    1.47 +  is(programs.length, 0,
    1.48 +    "There should be no cached program actors yet.");
    1.49 +
    1.50 +  yield globalCreated;
    1.51 +  let programs = yield front.getPrograms();
    1.52 +  is(programs.length, 1,
    1.53 +    "There should be 1 cached program actor now.");
    1.54 +
    1.55 +  yield checkHighlightingInTheFirstPage(programs[0]);
    1.56 +  ok(true, "The cached programs behave correctly after navigating back and reloading.");
    1.57 +
    1.58 +  // 3. Perform a bfcache navigation and a page reload.
    1.59 +
    1.60 +  yield navigateInHistory(target, "forward");
    1.61 +  let globalDestroyed = observe("inner-window-destroyed");
    1.62 +  let globalCreated = observe("content-document-global-created");
    1.63 +  reload(target);
    1.64 +
    1.65 +  yield globalDestroyed;
    1.66 +  let programs = yield front.getPrograms();
    1.67 +  is(programs.length, 0,
    1.68 +    "There should be no cached program actors yet.");
    1.69 +
    1.70 +  yield getPrograms(front, 2);
    1.71 +  yield globalCreated;
    1.72 +  let programs = yield front.getPrograms();
    1.73 +  is(programs.length, 2,
    1.74 +    "There should be 2 cached program actors now.");
    1.75 +
    1.76 +  yield checkHighlightingInTheSecondPage(programs[0], programs[1]);
    1.77 +  ok(true, "The cached programs behave correctly after navigating forward and reloading.");
    1.78 +
    1.79 +  yield removeTab(target.tab);
    1.80 +  finish();
    1.81 +
    1.82 +  function checkHighlightingInTheFirstPage(programActor) {
    1.83 +    return Task.spawn(function() {
    1.84 +      yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
    1.85 +      yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
    1.86 +      ok(true, "The corner pixel colors are correct before highlighting.");
    1.87 +
    1.88 +      yield programActor.highlight([0, 1, 0, 1]);
    1.89 +      yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true);
    1.90 +      yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
    1.91 +      ok(true, "The corner pixel colors are correct after highlighting.");
    1.92 +
    1.93 +      yield programActor.unhighlight();
    1.94 +      yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
    1.95 +      yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
    1.96 +      ok(true, "The corner pixel colors are correct after unhighlighting.");
    1.97 +    });
    1.98 +  }
    1.99 +
   1.100 +  function checkHighlightingInTheSecondPage(firstProgramActor, secondProgramActor) {
   1.101 +    return Task.spawn(function() {
   1.102 +      yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
   1.103 +      yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
   1.104 +      yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
   1.105 +      yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
   1.106 +      ok(true, "The two canvases are correctly drawn before highlighting.");
   1.107 +
   1.108 +      yield firstProgramActor.highlight([1, 0, 0, 1]);
   1.109 +      yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1");
   1.110 +      yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
   1.111 +      yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1");
   1.112 +      yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
   1.113 +      ok(true, "The first canvas was correctly filled after highlighting.");
   1.114 +
   1.115 +      yield secondProgramActor.highlight([0, 1, 0, 1]);
   1.116 +      yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1");
   1.117 +      yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 0, a: 255 }, true, "#canvas2");
   1.118 +      yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1");
   1.119 +      yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 0, a: 255 }, true, "#canvas2");
   1.120 +      ok(true, "The second canvas was correctly filled after highlighting.");
   1.121 +
   1.122 +      yield firstProgramActor.unhighlight();
   1.123 +      yield secondProgramActor.unhighlight();
   1.124 +      yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
   1.125 +      yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
   1.126 +      yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
   1.127 +      yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
   1.128 +      ok(true, "The two canvases were correctly filled after unhighlighting.");
   1.129 +    });
   1.130 +  }
   1.131 +}

mercurial