diff --git a/browser/devtools/styleinspector/test/browser.ini b/browser/devtools/styleinspector/test/browser.ini index b18aa29a6e37..ba2b398c1907 100644 --- a/browser/devtools/styleinspector/test/browser.ini +++ b/browser/devtools/styleinspector/test/browser.ini @@ -4,19 +4,31 @@ support-files = head.js browser_bug722196_identify_media_queries.html browser_styleinspector_bug_677930_urls_clickable/browser_styleinspector_bug_677930_urls_clickable.css + browser_bug683672.html + browser_bug705707_is_content_stylesheet.html + browser_bug705707_is_content_stylesheet_imported.css + browser_bug705707_is_content_stylesheet_imported2.css + browser_bug705707_is_content_stylesheet_linked.css + browser_bug705707_is_content_stylesheet_script.css + browser_bug705707_is_content_stylesheet.xul + browser_bug705707_is_content_stylesheet_xul.css + test-image.png + browser_styleinspector_bug_677930_urls_clickable.html + browser_ruleview_pseudoelement.html + sourcemaps.html + sourcemaps.css + sourcemaps.css.map + sourcemaps.scss + browser_ruleview_734259_style_editor_link.css [browser_bug683672.js] -support-files = browser_bug683672.html [browser_styleinspector_bug_672746_default_styles.js] [browser_styleinspector_bug_672744_search_filter.js] [browser_bug589375_keybindings.js] -skip-if = true # awaiting promise-based init [browser_styleinspector_bug_689759_no_results_placeholder.js] [browser_bug_692400_element_style.js] [browser_csslogic_inherited.js] [browser_ruleview_734259_style_editor_link.js] -support-files = - browser_ruleview_734259_style_editor_link.css [browser_ruleview_editor.js] [browser_ruleview_editor_changedvalues.js] [browser_ruleview_copy.js] @@ -29,14 +41,6 @@ support-files = [browser_ruleview_update.js] [browser_ruleview_livepreview.js] [browser_bug705707_is_content_stylesheet.js] -support-files = - browser_bug705707_is_content_stylesheet.html - browser_bug705707_is_content_stylesheet_imported.css - browser_bug705707_is_content_stylesheet_imported2.css - browser_bug705707_is_content_stylesheet_linked.css - browser_bug705707_is_content_stylesheet_script.css - browser_bug705707_is_content_stylesheet.xul - browser_bug705707_is_content_stylesheet_xul.css [browser_bug722196_property_view_media_queries.js] [browser_bug722196_rule_view_media_queries.js] [browser_bug_592743_specificity.js] @@ -44,16 +48,12 @@ support-files = [browser_computedview_734259_style_editor_link.js] [browser_computedview_copy.js] [browser_styleinspector_bug_677930_urls_clickable.js] -support-files = - test-image.png - browser_styleinspector_bug_677930_urls_clickable.html [browser_bug893965_css_property_completion_new_property.js] [browser_bug893965_css_property_completion_existing_property.js] [browser_bug894376_css_value_completion_new_property_value_pair.js] [browser_bug894376_css_value_completion_existing_property_value_pair.js] [browser_ruleview_bug_902966_revert_value_on_ESC.js] [browser_ruleview_pseudoelement.js] -support-files = browser_ruleview_pseudoelement.html [browser_computedview_bug835808_keyboard_nav.js] [browser_bug913014_matched_expand.js] [browser_bug765105_background_image_tooltip.js] @@ -62,11 +62,6 @@ support-files = browser_ruleview_pseudoelement.html [browser_bug702577_fontfamily_tooltip_longhand.js] [browser_bug940500_rule_view_pick_gradient_color.js] [browser_ruleview_original_source_link.js] -support-files = - sourcemaps.html - sourcemaps.css - sourcemaps.css.map - sourcemaps.scss [browser_computedview_original_source_link.js] [browser_bug946331_close_tooltip_on_new_selection.js] [browser_bug942297_user_property_reset.js] @@ -80,3 +75,4 @@ support-files = [browser_ruleview_colorpicker-and-image-tooltip_01.js] [browser_ruleview_colorpicker-and-image-tooltip_02.js] [browser_ruleview_colorpicker-multiple-changes.js] +[browser_ruleview_add_property_01.js] diff --git a/browser/devtools/styleinspector/test/browser_bug589375_keybindings.js b/browser/devtools/styleinspector/test/browser_bug589375_keybindings.js index c19529f889c8..6e5a25801461 100644 --- a/browser/devtools/styleinspector/test/browser_bug589375_keybindings.js +++ b/browser/devtools/styleinspector/test/browser_bug589375_keybindings.js @@ -1,92 +1,44 @@ /* 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/ */ + http://creativecommons.org/publicdomain/zero/1.0/ */ -// Tests that the key bindings work properly. +"use strict"; -let doc; -let inspector; -let computedView; -let iframe; +// Test computed view key bindings -function createDocument() -{ - doc.body.innerHTML = '' + 'Some styled text' + ''; - doc.title = "Style Inspector key binding test"; - openInspector(openComputedView); -} + let {toolbox, inspector, view} = yield openComputedView(); -function openComputedView(aInspector) -{ - inspector = aInspector; - iframe = inspector._toolbox.frame; + info("Selecting the test node"); + yield selectNode(".matches", inspector); - Services.obs.addObserver(runTests, "StyleInspector-populated", false); - - inspector.sidebar.select("computedview"); -} - -function runTests() -{ - Services.obs.removeObserver(runTests, "StyleInspector-populated"); - computedView = getComputedView(); - - var span = doc.querySelector(".matches"); - ok(span, "captain, we have the matches span"); - - inspector.selection.setNode(span); - - is(span, computedView.viewedElement, - "style inspector node matches the selected node"); - is(computedView.viewedElement, computedView.cssLogic.viewedElement, - "cssLogic node matches the cssHtmlTree node"); - - info("checking keybindings"); - - let searchbar = computedView.searchField; - let propView = getFirstVisiblePropertyView(); + let propView = getFirstVisiblePropertyView(view); let rulesTable = propView.matchedSelectorsContainer; - let matchedExpander = propView.matchedExpander; + let matchedExpander = propView.element; - info("Adding focus event handler to search filter"); - searchbar.addEventListener("focus", function searchbarFocused() { - searchbar.removeEventListener("focus", searchbarFocused); - info("search filter is focused"); - info("tabbing to property expander node"); - EventUtils.synthesizeKey("VK_TAB", {}, iframe.contentWindow); - }); + info("Focusing the property"); + let onMatchedExpanderFocus = once(matchedExpander, "focus", true); + EventUtils.synthesizeMouseAtCenter(matchedExpander, {}, view.styleWindow); + yield onMatchedExpanderFocus; - info("Adding focus event handler to property expander"); - matchedExpander.addEventListener("focus", function expanderFocused() { - matchedExpander.removeEventListener("focus", expanderFocused); - info("property expander is focused"); - info("checking expand / collapse"); - testKey(iframe.contentWindow, "VK_SPACE", rulesTable); - testKey(iframe.contentWindow, "VK_RETURN", rulesTable); + yield checkToggleKeyBinding(view.styleWindow, "VK_SPACE", rulesTable, inspector); + yield checkToggleKeyBinding(view.styleWindow, "VK_RETURN", rulesTable, inspector); + yield checkHelpLinkKeybinding(view); +}); - checkHelpLinkKeybinding(); - computedView.destroy(); - finishUp(); - }); - - info("Making sure that the style inspector panel is focused"); - SimpleTest.waitForFocus(function windowFocused() { - info("window is focused"); - info("focusing search filter"); - searchbar.focus(); - }, iframe.contentWindow); -} - -function getFirstVisiblePropertyView() -{ +function getFirstVisiblePropertyView(view) { let propView = null; - computedView.propertyViews.some(function(aPropView) { - if (aPropView.visible) { - propView = aPropView; + view.propertyViews.some(p => { + if (p.visible) { + propView = p; return true; } return false; @@ -95,47 +47,33 @@ function getFirstVisiblePropertyView() return propView; } -function testKey(aContext, aVirtKey, aRulesTable) -{ - info("testing " + aVirtKey + " key"); - info("expanding rules table"); - EventUtils.synthesizeKey(aVirtKey, {}, aContext); - isnot(aRulesTable.innerHTML, "", "rules Table is populated"); - info("collapsing rules table"); - EventUtils.synthesizeKey(aVirtKey, {}, aContext); - is(aRulesTable.innerHTML, "", "rules Table is not populated"); +function* checkToggleKeyBinding(win, key, rulesTable, inspector) { + info("Pressing " + key + " key a couple of times to check that the property gets expanded/collapsed"); + + let onExpand = inspector.once("computed-view-property-expanded"); + let onCollapse = inspector.once("computed-view-property-collapsed"); + + info("Expanding the property"); + EventUtils.synthesizeKey(key, {}, win); + yield onExpand; + isnot(rulesTable.innerHTML, "", "The property has been expanded"); + + info("Collapsing the property"); + EventUtils.synthesizeKey(key, {}, win); + yield onCollapse; + is(rulesTable.innerHTML, "", "The property has been collapsed"); } -function checkHelpLinkKeybinding() -{ - info("checking help link keybinding"); - let propView = getFirstVisiblePropertyView(); +function checkHelpLinkKeybinding(view) { + info("Check that MDN link is opened on \"F1\""); + let def = promise.defer(); - info("check that MDN link is opened on \"F1\""); - let linkClicked = false; + let propView = getFirstVisiblePropertyView(view); propView.mdnLinkClick = function(aEvent) { - linkClicked = true; + ok(true, "Pressing F1 opened the MDN link"); + def.resolve(); }; - EventUtils.synthesizeKey("VK_F1", {}, iframe.contentWindow); - is(linkClicked, true, "MDN link will be shown"); -} -function finishUp() -{ - doc = inspector = iframe = computedView = null; - gBrowser.removeCurrentTab(); - finish(); -} - -function test() -{ - waitForExplicitFinish(); - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) { - gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true); - doc = content.document; - waitForFocus(createDocument, content); - }, true); - - content.location = "data:text/html,default styles test"; + EventUtils.synthesizeKey("VK_F1", {}, view.styleWindow); + return def.promise; } diff --git a/browser/devtools/styleinspector/test/browser_bug683672.js b/browser/devtools/styleinspector/test/browser_bug683672.js index bc885c5d5daa..467a921e77d5 100644 --- a/browser/devtools/styleinspector/test/browser_bug683672.js +++ b/browser/devtools/styleinspector/test/browser_bug683672.js @@ -1,79 +1,36 @@ -/* vim: set ts=2 et sw=2 tw=80: */ +/* 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/ */ + http://creativecommons.org/publicdomain/zero/1.0/ */ -// Tests that the style inspector works properly +"use strict"; -let doc; -let inspector; -let div; -let computedView; +// Checking selector counts, matched rules and titles in the computed-view -const TEST_URI = "http://example.com/browser/browser/devtools/styleinspector/test/browser_bug683672.html"; +const {PropertyView} = devtools.require("devtools/styleinspector/computed-view"); +const TEST_URI = TEST_URL_ROOT + "browser_bug683672.html"; -let tempScope = {}; -let {CssHtmlTree, PropertyView} = devtools.require("devtools/styleinspector/computed-view"); -let {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {}); +let test = asyncTest(function*() { + yield addTab(TEST_URI); + let {toolbox, inspector, view} = yield openComputedView(); -function test() -{ - waitForExplicitFinish(); - addTab(TEST_URI); - browser.addEventListener("load", tabLoaded, true); -} + yield selectNode("#test", inspector); + yield testMatchedSelectors(view); +}); -function tabLoaded() -{ - browser.removeEventListener("load", tabLoaded, true); - doc = content.document; - openComputedView(selectNode); -} - -function selectNode(aInspector, aComputedView) -{ - inspector = aInspector; - computedView = aComputedView; - - div = content.document.getElementById("test"); - ok(div, "captain, we have the div"); - - inspector.selection.setNode(div); - inspector.once("inspector-updated", runTests); -} - -function runTests() -{ - testMatchedSelectors().then(() => { - info("finishing up"); - finishUp(); - }); -} - -function testMatchedSelectors() -{ +function* testMatchedSelectors(view) { info("checking selector counts, matched rules and titles"); - is(div, computedView.viewedElement.rawNode(), + is(getNode("#test"), view.viewedElement.rawNode(), "style inspector node matches the selected node"); - let propertyView = new PropertyView(computedView, "color"); + let propertyView = new PropertyView(view, "color"); propertyView.buildMain(); propertyView.buildSelectorContainer(); propertyView.matchedExpanded = true; - return propertyView.refreshMatchedSelectors().then(() => { - let numMatchedSelectors = propertyView.matchedSelectors.length; - is(numMatchedSelectors, 6, - "CssLogic returns the correct number of matched selectors for div"); + yield propertyView.refreshMatchedSelectors(); - is(propertyView.hasMatchedSelectors, true, - "hasMatchedSelectors returns true"); - }).then(null, (err) => console.error(err)); -} - -function finishUp() -{ - doc = inspector = div = computedView = null; - gBrowser.removeCurrentTab(); - finish(); + let numMatchedSelectors = propertyView.matchedSelectors.length; + is(numMatchedSelectors, 6, "CssLogic returns the correct number of matched selectors for div"); + is(propertyView.hasMatchedSelectors, true, "hasMatchedSelectors returns true"); } diff --git a/browser/devtools/styleinspector/test/browser_bug702577_fontfamily_tooltip_longhand.js b/browser/devtools/styleinspector/test/browser_bug702577_fontfamily_tooltip_longhand.js index b511888325c0..3ae695d56e0c 100644 --- a/browser/devtools/styleinspector/test/browser_bug702577_fontfamily_tooltip_longhand.js +++ b/browser/devtools/styleinspector/test/browser_bug702577_fontfamily_tooltip_longhand.js @@ -1,11 +1,10 @@ -/* vim: set ts=2 et sw=2 tw=80: */ +/* 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/ */ -let contentDoc; -let inspector; -let ruleView; -let computedView; +"use strict"; + +// Test the fontfamily tooltip on longhand properties const PAGE_CONTENT = [ '"; } -function finishUp() -{ - CssLogic = CssSelector = tempScope = null; - finish(); -} - -function test() -{ - waitForExplicitFinish(); - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) { - gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true); - waitForFocus(createDocument, content); - }, true); - - content.location = "data:text/html,Computed view specificity test"; +function getExpectedSpecificity(selectorText) { + return TEST_DATA.filter(i=>i.text === selectorText)[0].expected; } diff --git a/browser/devtools/styleinspector/test/browser_bug_692400_element_style.js b/browser/devtools/styleinspector/test/browser_bug_692400_element_style.js index 2f3d464f2b58..6b789ca8a6ca 100644 --- a/browser/devtools/styleinspector/test/browser_bug_692400_element_style.js +++ b/browser/devtools/styleinspector/test/browser_bug_692400_element_style.js @@ -1,77 +1,44 @@ /* 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/ */ + http://creativecommons.org/publicdomain/zero/1.0/ */ -// Tests for selector text errors. +"use strict"; -let doc; -let computedView; +// Tests for matched selector texts in the computed view -function createDocument() -{ - doc.body.innerHTML = "
"; +let test = asyncTest(function*() { + yield addTab("data:text/html,"); - doc.title = "Style Inspector Selector Text Test"; + info("Opening the computed view"); + let {toolbox, inspector, view} = yield openComputedView(); - openComputedView(startTests); -} + info("Selecting the test node"); + yield selectNode("div", inspector); + info("Checking the color property view"); + let propertyView = getPropertyView(view, "color"); + ok(propertyView, "found PropertyView for color"); + is(propertyView.hasMatchedSelectors, true, "hasMatchedSelectors is true"); -function startTests(aInspector, aComputedView) -{ - computedView = aComputedView; + info("Expanding the matched selectors"); + propertyView.matchedExpanded = true; + yield propertyView.refreshMatchedSelectors(); - let div = doc.querySelector("div"); - ok(div, "captain, we have the test div"); + let span = propertyView.matchedSelectorsContainer.querySelector("span.rule-text"); + ok(span, "Found the first table row"); - aInspector.selection.setNode(div); - aInspector.once("inspector-updated", SI_checkText); -} + let selector = propertyView.matchedSelectorViews[0]; + ok(selector, "Found the first matched selector view"); +}); -function SI_checkText() -{ +function getPropertyView(computedView, name) { let propertyView = null; - computedView.propertyViews.some(function(aView) { - if (aView.name == "color") { - propertyView = aView; + computedView.propertyViews.some(function(view) { + if (view.name == name) { + propertyView = view; return true; } return false; }); - - ok(propertyView, "found PropertyView for color"); - - is(propertyView.hasMatchedSelectors, true, "hasMatchedSelectors is true"); - - propertyView.matchedExpanded = true; - propertyView.refreshMatchedSelectors().then(() => { - - let span = propertyView.matchedSelectorsContainer.querySelector("span.rule-text"); - ok(span, "found the first table row"); - - let selector = propertyView.matchedSelectorViews[0]; - ok(selector, "found the first matched selector view"); - - finishUp(); - }); -} - -function finishUp() -{ - doc = computedView = null; - gBrowser.removeCurrentTab(); - finish(); -} - -function test() -{ - waitForExplicitFinish(); - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) { - gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true); - doc = content.document; - waitForFocus(createDocument, content); - }, true); - - content.location = "data:text/html,selector text test, bug 692400"; + return propertyView; } diff --git a/browser/devtools/styleinspector/test/browser_computedview_734259_style_editor_link.js b/browser/devtools/styleinspector/test/browser_computedview_734259_style_editor_link.js index c4a73e4798cc..488fe0804c36 100644 --- a/browser/devtools/styleinspector/test/browser_computedview_734259_style_editor_link.js +++ b/browser/devtools/styleinspector/test/browser_computedview_734259_style_editor_link.js @@ -2,9 +2,9 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -let doc; -let inspector; -let computedView; +"use strict"; + +// Test the links from the computed view to the style editor const STYLESHEET_URL = "data:text/css,"+encodeURIComponent( [".highlight {", @@ -40,128 +40,75 @@ const DOCUMENT_URL = "data:text/html,"+encodeURIComponent( '