browser/devtools/styleeditor/test/browser_styleeditor_bug_870339.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/styleeditor/test/browser_styleeditor_bug_870339.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,46 @@
     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 +{
     1.9 +  const SIMPLE = TEST_BASE_HTTP + "simple.css";
    1.10 +  const DOCUMENT_WITH_ONE_STYLESHEET = "data:text/html;charset=UTF-8," +
    1.11 +          encodeURIComponent(
    1.12 +            ["<!DOCTYPE html>",
    1.13 +             "<html>",
    1.14 +             " <head>",
    1.15 +             "  <title>Bug 870339</title>",
    1.16 +             '  <link rel="stylesheet" type="text/css" href="'+SIMPLE+'">',
    1.17 +             " </head>",
    1.18 +             " <body>",
    1.19 +             " </body>",
    1.20 +             "</html>"
    1.21 +            ].join("\n"));
    1.22 +
    1.23 +  waitForExplicitFinish();
    1.24 +  addTabAndOpenStyleEditors(1, function (aPanel) {
    1.25 +    let UI = aPanel.UI;
    1.26 +
    1.27 +    // Spam the _onNewDocument callback multiple times before the
    1.28 +    // StyleEditorActor has a chance to respond to the first one.
    1.29 +    const SPAM_COUNT = 2;
    1.30 +    for (let i=0; i<SPAM_COUNT; ++i) {
    1.31 +      UI._onNewDocument();
    1.32 +    }
    1.33 +
    1.34 +    // Wait for the StyleEditorActor to respond to each "newDocument"
    1.35 +    // message.
    1.36 +    let loadCount = 0;
    1.37 +    UI.on("stylesheets-reset", function () {
    1.38 +      ++loadCount;
    1.39 +      if (loadCount == SPAM_COUNT) {
    1.40 +        // No matter how large SPAM_COUNT is, the number of style
    1.41 +        // sheets should never be more than the number of style sheets
    1.42 +        // in the document.
    1.43 +        is(UI.editors.length, 1, "correct style sheet count");
    1.44 +        finish();
    1.45 +      }
    1.46 +    });
    1.47 +  });
    1.48 +  content.location = DOCUMENT_WITH_ONE_STYLESHEET;
    1.49 +}

mercurial