browser/devtools/inspector/test/browser_inspector_invalidate.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/inspector/test/browser_inspector_invalidate.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,51 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +function test() {
     1.8 +  let doc;
     1.9 +  let div;
    1.10 +  let inspector;
    1.11 +
    1.12 +  function createDocument() {
    1.13 +    div = doc.createElement("div");
    1.14 +    div.setAttribute("style", "width: 100px; height: 100px; background:yellow;");
    1.15 +    doc.body.appendChild(div);
    1.16 +
    1.17 +    openInspector(aInspector => {
    1.18 +      inspector = aInspector;
    1.19 +      inspector.toolbox.highlighter.showBoxModel(getNodeFront(div)).then(runTest);
    1.20 +    });
    1.21 +  }
    1.22 +
    1.23 +  function runTest() {
    1.24 +    let rect = getSimpleBorderRect();
    1.25 +    is(rect.width, 100, "outline has the right width");
    1.26 +
    1.27 +    div.style.width = "200px";
    1.28 +    inspector.toolbox.once("highlighter-ready", testRectWidth);
    1.29 +  }
    1.30 +
    1.31 +  function testRectWidth() {
    1.32 +    let rect = getSimpleBorderRect();
    1.33 +    is(rect.width, 200, "outline updated");
    1.34 +    finishUp();
    1.35 +  }
    1.36 +
    1.37 +  function finishUp() {
    1.38 +    inspector.toolbox.highlighter.hideBoxModel().then(() => {
    1.39 +      doc = div = inspector = null;
    1.40 +      gBrowser.removeCurrentTab();
    1.41 +      finish();
    1.42 +    });
    1.43 +  }
    1.44 +
    1.45 +  waitForExplicitFinish();
    1.46 +  gBrowser.selectedTab = gBrowser.addTab();
    1.47 +  gBrowser.selectedBrowser.addEventListener("load", function() {
    1.48 +    gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
    1.49 +    doc = content.document;
    1.50 +    waitForFocus(createDocument, content);
    1.51 +  }, true);
    1.52 +
    1.53 +  content.location = "data:text/html;charset=utf-8,browser_inspector_invalidate.js";
    1.54 +}

mercurial