gecko/browser/devtools/styleinspector/test/browser_ruleview_completion-new-property_02.js
Patrick Brosset 50959813c8 Bug 988313 - Rename devtools/styleinspector tests for consistency reasons. r=miker
--HG--
rename : browser/devtools/styleinspector/test/browser_styleinspector_bug_672746_default_styles.js => browser/devtools/styleinspector/test/browser_computedview_browser-styles.js
rename : browser/devtools/styleinspector/test/browser_bug589375_keybindings.js => browser/devtools/styleinspector/test/browser_computedview_keybindings_01.js
rename : browser/devtools/styleinspector/test/browser_computedview_bug835808_keyboard_nav.js => browser/devtools/styleinspector/test/browser_computedview_keybindings_02.js
rename : browser/devtools/styleinspector/test/browser_bug913014_matched_expand.js => browser/devtools/styleinspector/test/browser_computedview_matched-selectors-toggle.js
rename : browser/devtools/styleinspector/test/browser_bug683672.js => browser/devtools/styleinspector/test/browser_computedview_matched-selectors_01.js
rename : browser/devtools/styleinspector/test/browser_bug_692400_element_style.js => browser/devtools/styleinspector/test/browser_computedview_matched-selectors_02.js
rename : browser/devtools/styleinspector/test/browser_bug722196_property_view_media_queries.js => browser/devtools/styleinspector/test/browser_computedview_media-queries.js
rename : browser/devtools/styleinspector/test/browser_styleinspector_bug_689759_no_results_placeholder.js => browser/devtools/styleinspector/test/browser_computedview_no-results-placeholder.js
rename : browser/devtools/styleinspector/test/browser_computedview_original_source_link.js => browser/devtools/styleinspector/test/browser_computedview_original-source-link.js
rename : browser/devtools/styleinspector/test/browser_styleinspector_bug_672744_search_filter.js => browser/devtools/styleinspector/test/browser_computedview_search-filter.js
rename : browser/devtools/styleinspector/test/browser_computedview_copy.js => browser/devtools/styleinspector/test/browser_computedview_select-and-copy-styles.js
rename : browser/devtools/styleinspector/test/browser_computedview_734259_style_editor_link.js => browser/devtools/styleinspector/test/browser_computedview_style-editor-link.js
rename : browser/devtools/styleinspector/test/browser_ruleview_add_property_01.js => browser/devtools/styleinspector/test/browser_ruleview_add-property-and-reselect.js
rename : browser/devtools/styleinspector/test/browser_ruleview_editor_changedvalues_01.js => browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_01.js
rename : browser/devtools/styleinspector/test/browser_ruleview_editor_changedvalues_03.js => browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_02.js
rename : browser/devtools/styleinspector/test/browser_ruleview_cancel.js => browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_03.js
rename : browser/devtools/styleinspector/test/browser_ruleview_editor_changedvalues_02.js => browser/devtools/styleinspector/test/browser_ruleview_add-property_01.js
rename : browser/devtools/styleinspector/test/browser_ruleview_add_property_02.js => browser/devtools/styleinspector/test/browser_ruleview_add-property_02.js
rename : browser/devtools/styleinspector/test/browser_bug940500_rule_view_pick_gradient_color.js => browser/devtools/styleinspector/test/browser_ruleview_colorpicker-edit-gradient.js
rename : browser/devtools/styleinspector/test/browser_bug893965_css_property_completion_existing_property.js => browser/devtools/styleinspector/test/browser_ruleview_completion-existing-property_01.js
rename : browser/devtools/styleinspector/test/browser_bug894376_css_value_completion_existing_property_value_pair.js => browser/devtools/styleinspector/test/browser_ruleview_completion-existing-property_02.js
rename : browser/devtools/styleinspector/test/browser_bug893965_css_property_completion_new_property.js => browser/devtools/styleinspector/test/browser_ruleview_completion-new-property_01.js
rename : browser/devtools/styleinspector/test/browser_bug894376_css_value_completion_new_property_value_pair.js => browser/devtools/styleinspector/test/browser_ruleview_completion-new-property_02.js
rename : browser/devtools/styleinspector/test/browser_ruleview_bug_902966_revert_value_on_ESC.js => browser/devtools/styleinspector/test/browser_ruleview_edit-property-commit.js
rename : browser/devtools/styleinspector/test/browser_bug722691_rule_view_increment.js => browser/devtools/styleinspector/test/browser_ruleview_edit-property-increments.js
rename : browser/devtools/styleinspector/test/browser_ruleview_manipulation.js => browser/devtools/styleinspector/test/browser_ruleview_edit-property-order.js
rename : browser/devtools/styleinspector/test/browser_ruleview_editor_changedvalues_04.js => browser/devtools/styleinspector/test/browser_ruleview_edit-property_01.js
rename : browser/devtools/styleinspector/test/browser_ruleview_edit.js => browser/devtools/styleinspector/test/browser_ruleview_edit-property_02.js
rename : browser/devtools/styleinspector/test/browser_ruleview_focus.js => browser/devtools/styleinspector/test/browser_ruleview_keybindings.js
rename : browser/devtools/styleinspector/test/browser_bug970532_mathml_element.js => browser/devtools/styleinspector/test/browser_ruleview_mathml-element.js
rename : browser/devtools/styleinspector/test/browser_bug722196_rule_view_media_queries.js => browser/devtools/styleinspector/test/browser_ruleview_media-queries.js
rename : browser/devtools/styleinspector/test/browser_ruleview_multiple_properties_02.js => browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-duplicates.js
rename : browser/devtools/styleinspector/test/browser_ruleview_multiple_properties_03.js => browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-priority.js
rename : browser/devtools/styleinspector/test/browser_ruleview_multiple_properties_04.js => browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-unfinished_01.js
rename : browser/devtools/styleinspector/test/browser_ruleview_multiple_properties_05.js => browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-unfinished_02.js
rename : browser/devtools/styleinspector/test/browser_ruleview_original_source_link.js => browser/devtools/styleinspector/test/browser_ruleview_original-source-link.js
rename : browser/devtools/styleinspector/test/browser_ruleview_pseudoelement.js => browser/devtools/styleinspector/test/browser_ruleview_pseudo-element.js
rename : browser/devtools/styleinspector/test/browser_ruleview_copy.js => browser/devtools/styleinspector/test/browser_ruleview_select-and-copy-styles.js
rename : browser/devtools/styleinspector/test/browser_ruleview_734259_style_editor_link.js => browser/devtools/styleinspector/test/browser_ruleview_style-editor-link.js
rename : browser/devtools/styleinspector/test/browser_styleinspector_bug_677930_urls_clickable.js => browser/devtools/styleinspector/test/browser_ruleview_urls-clickable.js
rename : browser/devtools/styleinspector/test/browser_bug942297_user_property_reset.js => browser/devtools/styleinspector/test/browser_ruleview_user-property-reset.js
rename : browser/devtools/styleinspector/test/browser_bug705707_is_content_stylesheet.js => browser/devtools/styleinspector/test/browser_styleinspector_csslogic-content-stylesheets.js
rename : browser/devtools/styleinspector/test/browser_csslogic_inherited.js => browser/devtools/styleinspector/test/browser_styleinspector_csslogic-inherited-properties.js
rename : browser/devtools/styleinspector/test/browser_bug_592743_specificity.js => browser/devtools/styleinspector/test/browser_styleinspector_csslogic-specificity.js
rename : browser/devtools/styleinspector/test/browser_ruleview_editor.js => browser/devtools/styleinspector/test/browser_styleinspector_inplace-editor.js
rename : browser/devtools/styleinspector/test/browser_styleinspector_outputparser.js => browser/devtools/styleinspector/test/browser_styleinspector_output-parser.js
rename : browser/devtools/styleinspector/test/browser_bug765105_background_image_tooltip.js => browser/devtools/styleinspector/test/browser_styleinspector_tooltip-background-image.js
rename : browser/devtools/styleinspector/test/browser_bug946331_close_tooltip_on_new_selection.js => browser/devtools/styleinspector/test/browser_styleinspector_tooltip-closes-on-new-selection.js
rename : browser/devtools/styleinspector/test/browser_bug702577_fontfamily_tooltip_longhand.js => browser/devtools/styleinspector/test/browser_styleinspector_tooltip-longhand-fontfamily.js
rename : browser/devtools/styleinspector/test/browser_bug702577_fontfamily_tooltip_shorthand.js => browser/devtools/styleinspector/test/browser_styleinspector_tooltip-shorthand-fontfamily.js
rename : browser/devtools/styleinspector/test/browser_bug726427_csstransform_tooltip.js => browser/devtools/styleinspector/test/browser_styleinspector_tooltip-transform.js
rename : browser/devtools/styleinspector/test/browser_bug705707_is_content_stylesheet.html => browser/devtools/styleinspector/test/doc_content_stylesheet.html
rename : browser/devtools/styleinspector/test/browser_bug705707_is_content_stylesheet.xul => browser/devtools/styleinspector/test/doc_content_stylesheet.xul
rename : browser/devtools/styleinspector/test/browser_bug705707_is_content_stylesheet_imported.css => browser/devtools/styleinspector/test/doc_content_stylesheet_imported.css
rename : browser/devtools/styleinspector/test/browser_bug705707_is_content_stylesheet_imported2.css => browser/devtools/styleinspector/test/doc_content_stylesheet_imported2.css
rename : browser/devtools/styleinspector/test/browser_bug705707_is_content_stylesheet_linked.css => browser/devtools/styleinspector/test/doc_content_stylesheet_linked.css
rename : browser/devtools/styleinspector/test/browser_bug705707_is_content_stylesheet_script.css => browser/devtools/styleinspector/test/doc_content_stylesheet_script.css
rename : browser/devtools/styleinspector/test/browser_bug705707_is_content_stylesheet_xul.css => browser/devtools/styleinspector/test/doc_content_stylesheet_xul.css
rename : browser/devtools/styleinspector/test/browser_bug683672.html => browser/devtools/styleinspector/test/doc_matched_selectors.html
rename : browser/devtools/styleinspector/test/browser_bug722196_identify_media_queries.html => browser/devtools/styleinspector/test/doc_media_queries.html
rename : browser/devtools/styleinspector/test/browser_ruleview_pseudoelement.html => browser/devtools/styleinspector/test/doc_pseudoelement.html
rename : browser/devtools/styleinspector/test/sourcemaps.css => browser/devtools/styleinspector/test/doc_sourcemaps.css
rename : browser/devtools/styleinspector/test/sourcemaps.css.map => browser/devtools/styleinspector/test/doc_sourcemaps.css.map
rename : browser/devtools/styleinspector/test/sourcemaps.html => browser/devtools/styleinspector/test/doc_sourcemaps.html
rename : browser/devtools/styleinspector/test/sourcemaps.scss => browser/devtools/styleinspector/test/doc_sourcemaps.scss
rename : browser/devtools/styleinspector/test/browser_ruleview_734259_style_editor_link.css => browser/devtools/styleinspector/test/doc_style_editor_link.css
rename : browser/devtools/styleinspector/test/test-image.png => browser/devtools/styleinspector/test/doc_test_image.png
rename : browser/devtools/styleinspector/test/browser_styleinspector_bug_677930_urls_clickable/browser_styleinspector_bug_677930_urls_clickable.css => browser/devtools/styleinspector/test/doc_urls_clickable.css
rename : browser/devtools/styleinspector/test/browser_styleinspector_bug_677930_urls_clickable.html => browser/devtools/styleinspector/test/doc_urls_clickable.html
2014-04-08 12:19:24 +02:00

104 lines
3.7 KiB
JavaScript

/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that CSS property names and values are autocompleted and cycled correctly
// when editing new properties in the rule view
// format :
// [
// what key to press,
// modifers,
// expected input box value after keypress,
// selectedIndex of the popup,
// total items in the popup
// ]
let testData = [
["a", {accelKey: true, ctrlKey: true}, "", -1, 0],
["d", {}, "direction", 0, 3],
["VK_DOWN", {}, "display", 1, 3],
["VK_TAB", {}, "", -1, 10],
["VK_DOWN", {}, "-moz-box", 0, 10],
["n", {}, "none", -1, 0],
["VK_TAB", {shiftKey: true}, "display", -1, 0],
["VK_BACK_SPACE", {}, "", -1, 0],
["c", {}, "caption-side", 0, 10],
["o", {}, "color", 0, 6],
["VK_TAB", {}, "none", -1, 0],
["r", {}, "red", 0, 5],
["VK_DOWN", {}, "rgb", 1, 5],
["VK_DOWN", {}, "rgba", 2, 5],
["VK_DOWN", {}, "rosybrown", 3, 5],
["VK_DOWN", {}, "royalblue", 4, 5],
["VK_RIGHT", {}, "royalblue", -1, 0],
[" ", {}, "royalblue !important", 0, 10],
["!", {}, "royalblue !important", 0, 0],
["VK_ESCAPE", {}, null, -1, 0]
];
let TEST_URL = "data:text/html,<h1 style='border: 1px solid red'>Filename:"+
" browser_bug894376_css_value_completion_new_property_value_pair.js</h1>";
let test = asyncTest(function*() {
yield addTab(TEST_URL);
let {toolbox, inspector, view} = yield openRuleView();
info("Selecting the test node");
yield selectNode("h1", inspector);
info("Focusing a new css property editable property");
let brace = view.doc.querySelectorAll(".ruleview-ruleclose")[0];
let editor = yield focusEditableField(brace);
info("Starting to test for css property completion");
for (let i = 0; i < testData.length; i ++) {
// Re-define the editor at each iteration, because the focus may have moved
// from property to value and back
editor = inplaceEditor(view.doc.activeElement);
yield testCompletion(testData[i], editor, view);
}
});
function* testCompletion([key, modifiers, completion, index, total], editor, view) {
info("Pressing key " + key);
info("Expecting " + completion + ", " + index + ", " + total);
let onKeyPress;
if (/tab/ig.test(key)) {
info("Waiting for the new property or value editor to get focused");
let brace = view.doc.querySelector(".ruleview-ruleclose");
onKeyPress = once(brace.parentNode, "focus", true);
} else if (/(right|back_space|escape|return)/ig.test(key) ||
(modifiers.accelKey || modifiers.ctrlKey)) {
info("Adding event listener for right|escape|back_space|return keys");
onKeyPress = once(editor.input, "keypress");
} else {
info("Waiting for after-suggest event on the editor");
onKeyPress = editor.once("after-suggest");
}
info("Synthesizing key " + key + ", modifiers: " + Object.keys(modifiers));
EventUtils.synthesizeKey(key, modifiers, view.doc.defaultView);
yield onKeyPress;
yield wait(1); // Equivalent of executeSoon
info("Checking the state");
if (completion != null) {
// The key might have been a TAB or shift-TAB, in which case the editor will
// be a new one
editor = inplaceEditor(view.doc.activeElement);
is(editor.input.value, completion, "Correct value is autocompleted");
}
if (total == 0) {
ok(!(editor.popup && editor.popup.isOpen), "Popup is closed");
} else {
ok(editor.popup._panel.state == "open" || editor.popup._panel.state == "showing", "Popup is open");
is(editor.popup.getItems().length, total, "Number of suggestions match");
is(editor.popup.selectedIndex, index, "Correct item is selected");
}
}