browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_01.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.

     1 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
     2 /* Any copyright is dedicated to the Public Domain.
     3  http://creativecommons.org/publicdomain/zero/1.0/ */
     5 "use strict";
     7 // Testing various inplace-editor behaviors in the rule-view
     9 let TEST_URL = 'url("' + TEST_URL_ROOT + 'doc_test_image.png")';
    10 let PAGE_CONTENT = [
    11   '<style type="text/css">',
    12   '  #testid {',
    13   '    background-color: blue;',
    14   '  }',
    15   '  .testclass {',
    16   '    background-color: green;',
    17   '  }',
    18   '</style>',
    19   '<div id="testid" class="testclass">Styled Node</div>'
    20 ].join("\n");
    22 let test = asyncTest(function*() {
    23   yield addTab("data:text/html,test rule view user changes");
    25   info("Creating the test document");
    26   content.document.body.innerHTML = PAGE_CONTENT;
    28   info("Opening the rule-view");
    29   let {toolbox, inspector, view} = yield openRuleView();
    31   info("Selecting the test element");
    32   yield selectNode("#testid", inspector);
    34   yield testCancelNew(view);
    35 });
    37 function* testCancelNew(view) {
    38   info("Test adding a new rule to the element's style declaration and leaving it empty.");
    40   let elementRuleEditor = view.element.children[0]._ruleEditor;
    42   info("Focusing a new property name in the rule-view");
    43   let editor = yield focusEditableField(elementRuleEditor.closeBrace);
    44   is(inplaceEditor(elementRuleEditor.newPropSpan), editor, "The new property editor got focused");
    46   info("Bluring the editor input");
    47   let onBlur = once(editor.input, "blur");
    48   editor.input.blur();
    49   yield onBlur;
    51   info("Checking the state of canceling a new property name editor");
    52   ok(!elementRuleEditor.rule._applyingModifications, "Shouldn't have an outstanding request after a cancel.");
    53   is(elementRuleEditor.rule.textProps.length,  0, "Should have canceled creating a new text property.");
    54   ok(!elementRuleEditor.propertyList.hasChildNodes(), "Should not have any properties.");
    55 }

mercurial