browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_01.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     1.4 +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
     1.5 +/* Any copyright is dedicated to the Public Domain.
     1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */
     1.7 +
     1.8 +"use strict";
     1.9 +
    1.10 +// Testing various inplace-editor behaviors in the rule-view
    1.11 +
    1.12 +let TEST_URL = 'url("' + TEST_URL_ROOT + 'doc_test_image.png")';
    1.13 +let PAGE_CONTENT = [
    1.14 +  '<style type="text/css">',
    1.15 +  '  #testid {',
    1.16 +  '    background-color: blue;',
    1.17 +  '  }',
    1.18 +  '  .testclass {',
    1.19 +  '    background-color: green;',
    1.20 +  '  }',
    1.21 +  '</style>',
    1.22 +  '<div id="testid" class="testclass">Styled Node</div>'
    1.23 +].join("\n");
    1.24 +
    1.25 +let test = asyncTest(function*() {
    1.26 +  yield addTab("data:text/html,test rule view user changes");
    1.27 +
    1.28 +  info("Creating the test document");
    1.29 +  content.document.body.innerHTML = PAGE_CONTENT;
    1.30 +
    1.31 +  info("Opening the rule-view");
    1.32 +  let {toolbox, inspector, view} = yield openRuleView();
    1.33 +
    1.34 +  info("Selecting the test element");
    1.35 +  yield selectNode("#testid", inspector);
    1.36 +
    1.37 +  yield testCancelNew(view);
    1.38 +});
    1.39 +
    1.40 +function* testCancelNew(view) {
    1.41 +  info("Test adding a new rule to the element's style declaration and leaving it empty.");
    1.42 +
    1.43 +  let elementRuleEditor = view.element.children[0]._ruleEditor;
    1.44 +
    1.45 +  info("Focusing a new property name in the rule-view");
    1.46 +  let editor = yield focusEditableField(elementRuleEditor.closeBrace);
    1.47 +  is(inplaceEditor(elementRuleEditor.newPropSpan), editor, "The new property editor got focused");
    1.48 +
    1.49 +  info("Bluring the editor input");
    1.50 +  let onBlur = once(editor.input, "blur");
    1.51 +  editor.input.blur();
    1.52 +  yield onBlur;
    1.53 +
    1.54 +  info("Checking the state of canceling a new property name editor");
    1.55 +  ok(!elementRuleEditor.rule._applyingModifications, "Shouldn't have an outstanding request after a cancel.");
    1.56 +  is(elementRuleEditor.rule.textProps.length,  0, "Should have canceled creating a new text property.");
    1.57 +  ok(!elementRuleEditor.propertyList.hasChildNodes(), "Should not have any properties.");
    1.58 +}

mercurial