diff --git a/b2g/config/aries/sources.xml b/b2g/config/aries/sources.xml index e5c56329f612..023ddbffb4fe 100644 --- a/b2g/config/aries/sources.xml +++ b/b2g/config/aries/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/dolphin/sources.xml b/b2g/config/dolphin/sources.xml index 128c2c71ef81..a189e51130a4 100644 --- a/b2g/config/dolphin/sources.xml +++ b/b2g/config/dolphin/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index f580371a2bf3..2e969d0a9240 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 916883c6a13a..ead4bb103887 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 874166ff5348..b493a15309ff 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator-l/sources.xml b/b2g/config/emulator-l/sources.xml index 02edd3d5d5d2..03dc44271970 100644 --- a/b2g/config/emulator-l/sources.xml +++ b/b2g/config/emulator-l/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index f580371a2bf3..2e969d0a9240 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame-kk/sources.xml b/b2g/config/flame-kk/sources.xml index d7cea67158ef..0949076df167 100644 --- a/b2g/config/flame-kk/sources.xml +++ b/b2g/config/flame-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index dad9c7614a2c..b0f4f2c01a92 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,9 +1,9 @@ { "git": { - "git_revision": "9a8880a95ee4a4aea7895d4e2bcab31bc49ea281", + "git_revision": "2d7f369fd923b6df3b00d76844c413c1202c04ba", "remote": "https://git.mozilla.org/releases/gaia.git", "branch": "" }, - "revision": "aa0cf409f343d966a552839ab5d3bc85d1ebdda9", + "revision": "5c86f4cf87b91d2bfe9a3e49aa8706b452e4f97e", "repo_path": "integration/gaia-central" } diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index d1ac345b93f7..e3794d1f1789 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/nexus-5-l/sources.xml b/b2g/config/nexus-5-l/sources.xml index 1652b39ed658..c88fbf33d90a 100644 --- a/b2g/config/nexus-5-l/sources.xml +++ b/b2g/config/nexus-5-l/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/browser/base/content/test/general/browser.ini b/browser/base/content/test/general/browser.ini index ed923dda42c7..b9ab4683d903 100644 --- a/browser/base/content/test/general/browser.ini +++ b/browser/base/content/test/general/browser.ini @@ -357,6 +357,7 @@ skip-if = buildapp == 'mulet' || e10s # Bug 1101973 - breaks the next test in e1 skip-if = buildapp == 'mulet' [browser_private_no_prompt.js] skip-if = buildapp == 'mulet' +[browser_purgehistory_clears_sh.js] [browser_PageMetaData_pushstate.js] [browser_relatedTabs.js] [browser_remoteTroubleshoot.js] diff --git a/browser/base/content/test/general/browser_purgehistory_clears_sh.js b/browser/base/content/test/general/browser_purgehistory_clears_sh.js new file mode 100644 index 000000000000..80b3ec491b5e --- /dev/null +++ b/browser/base/content/test/general/browser_purgehistory_clears_sh.js @@ -0,0 +1,66 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +const url = "http://example.org/browser/browser/base/content/test/general/dummy_page.html"; + +add_task(function* purgeHistoryTest() { + let tab = yield BrowserTestUtils.withNewTab({ + gBrowser, + url, + }, function* purgeHistoryTestInner(browser) { + let backButton = browser.ownerDocument.getElementById("Browser:Back"); + let forwardButton = browser.ownerDocument.getElementById("Browser:Forward"); + + ok(!browser.webNavigation.canGoBack, + "Initial value for webNavigation.canGoBack"); + ok(!browser.webNavigation.canGoForward, + "Initial value for webNavigation.canGoBack"); + ok(backButton.hasAttribute("disabled"), "Back button is disabled"); + ok(forwardButton.hasAttribute("disabled"), "Forward button is disabled"); + + let pushState = ContentTask.spawn(browser, null, function*() { + let startHistory = content.history.length; + content.history.pushState({}, ""); + content.history.pushState({}, ""); + content.history.back(); + let newHistory = content.history.length; + return [startHistory, newHistory]; + }); + + let [startHistory, newHistory] = yield pushState; + + is(startHistory, 1, "Initial SHistory size"); + is(newHistory, 3, "New SHistory size"); + + ok(browser.webNavigation.canGoBack, true, + "New value for webNavigation.canGoBack"); + ok(browser.webNavigation.canGoForward, true, + "New value for webNavigation.canGoForward"); + ok(!backButton.hasAttribute("disabled"), "Back button was enabled"); + ok(!forwardButton.hasAttribute("disabled"), "Forward button was enabled"); + + + let tmp = {}; + Cc["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Ci.mozIJSSubScriptLoader) + .loadSubScript("chrome://browser/content/sanitize.js", tmp); + + let {Sanitizer} = tmp; + let sanitizer = new Sanitizer(); + + yield sanitizer.sanitize(["history"]); + + let historyAfterPurge = yield ContentTask.spawn(browser, null, function*() { + return content.history.length; + }); + + is(historyAfterPurge, 1, "SHistory correctly cleared"); + + ok(!browser.webNavigation.canGoBack, + "webNavigation.canGoBack correctly cleared"); + ok(!browser.webNavigation.canGoForward, + "webNavigation.canGoForward correctly cleared"); + ok(backButton.hasAttribute("disabled"), "Back button was disabled"); + ok(forwardButton.hasAttribute("disabled"), "Forward button was disabled"); + }); +}); diff --git a/browser/components/loop/content/css/contacts.css b/browser/components/loop/content/css/contacts.css index 9b673a19a0eb..381bb89c3e03 100644 --- a/browser/components/loop/content/css/contacts.css +++ b/browser/components/loop/content/css/contacts.css @@ -2,6 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +html { + font-size: 10px; + font-family: sans-serif; /* XXX will be changed to a system font in bug 1191398 */ +} + .contact-import-spinner { display: none; } @@ -281,8 +286,26 @@ html[dir="rtl"] .contact > .dropdown-menu { top: auto; } -.contact-form > .button-group { - margin-top: 1rem; +.contact-form { + padding: 14px; /* Override based on spacing in Mockup */ +} +/* This will effect the header displayed at the top of the contact details form + */ +.contact-form header { + text-align: center; + font-size: 1.3rem; + font-weight: 500; + color: #4a4a4a; +} + +.contact-form .form-content-container { + height: 24.1rem; /* This height is needed to keep the panel height at 400px and + the bottom elements at the bottom of the panel + Can likely go away if we switched this pane to flexbox model */ + padding-top: 4px; /* Based on spacing in Mockup + replaced margin-top + See http://stackoverflow.com/questions/6204670/css-clean-solution-to-the-margin-collapse-issue-when-floating-an-element + */ } .contacts-gravatar-promo { diff --git a/browser/components/loop/content/css/panel.css b/browser/components/loop/content/css/panel.css index 4330fa75715d..3e2caa737f70 100644 --- a/browser/components/loop/content/css/panel.css +++ b/browser/components/loop/content/css/panel.css @@ -15,6 +15,8 @@ body { .panel { /* hide the extra margin space that the panel resizer now wants to show */ overflow: hidden; + font: menu; + background-color: #fbfbfb; } /* Notifications displayed over tabs */ @@ -83,8 +85,6 @@ body { .tab-view > li { display: inline-block; - vertical-align: middle; - line-height: 1.2rem; text-align: center; padding: 0; cursor: pointer; @@ -252,20 +252,26 @@ html[dir="rtl"] .tab-view li:nth-child(2).selected ~ .slide-bar { display: block; width: 100%; outline: none; - border-radius: 2px; - margin: 5px 0; - border: 1px solid #ccc; - height: 24px; - padding: 0 10px; -} - -.content-area input:invalid { + border-radius: 4px; + margin: 10px 0; + border: 1px solid #c3c3c3; + height: 2.6rem; + padding: 0 6px; + font-size: 1.1rem; + color: #4a4a4a; box-shadow: none; } +.content-area input::-moz-placeholder { + color: #999; +} + .content-area input:not(.pristine):invalid { - border-color: #d74345; - box-shadow: 0 0 4px #c43c3e; + border: 0.1rem solid #d13f1a; +} + +.content-area input:focus { + border: 0.1rem solid #5cccee; } /* Rooms */ @@ -475,11 +481,17 @@ html[dir="rtl"] .tab-view li:nth-child(2).selected ~ .slide-bar { display: flex; flex-direction: row; width: 100%; + padding-top: 6px; } .button-group > .button { flex: 1; - margin: 0 7px; + margin: 0 5px; + min-height: 3rem; + font-size: 1.2rem; + line-height: 1rem; + font-weight: 300; + border-radius: 4px; } .button-group > .button:first-child { @@ -494,11 +506,11 @@ html[dir="rtl"] .tab-view li:nth-child(2).selected ~ .slide-bar { padding: 2px 5px; background-color: #fbfbfb; color: #333; - border: 1px solid #c1c1c1; border-radius: 2px; min-height: 26px; font-size: 1.2rem; line-height: 1.2rem; + border: none; } .button:hover { @@ -507,27 +519,39 @@ html[dir="rtl"] .tab-view li:nth-child(2).selected ~ .slide-bar { .button:hover:active { background-color: #ccc; - color: #111; + color: #fff; } .button.button-accept { - background-color: #5bc0a4; - border-color: #5bc0a4; - color: #fff; -} - -.button.button-accept:hover { - background-color: #47b396; - border-color: #47b396; + background-color: #00a9dc; color: #fff; } +.button.button-accept:hover, .button.button-accept:hover:active { - background-color: #3aa689; - border-color: #3aa689; + background-color: #5cccee; color: #fff; } +.button.button-cancel { + background-color: #ebebeb; + border: 0; + color: #000; + width: 105px; /* based on fixed width of Cancel button from mockup */ + flex: 0 0 auto; +} + +.button.button-cancel:hover, +.button.button-cancel:hover:active { + background-color: #dcd6d6; + color: #000; +} + +.button.button-cancel:disabled { + background-color: #ebebeb; + color: #c3c3c3; +} + .button-close { background-color: transparent; background-image: url(../shared/img/icons-10x10.svg#close); diff --git a/browser/components/loop/content/js/contacts.js b/browser/components/loop/content/js/contacts.js index f5625bf412c6..336663168e8d 100644 --- a/browser/components/loop/content/js/contacts.js +++ b/browser/components/loop/content/js/contacts.js @@ -740,31 +740,40 @@ loop.contacts = (function(_, mozL10n) { render: function() { let cx = React.addons.classSet; let phoneOrEmailRequired = !this.state.email && !this.state.tel; + let contactFormMode = "contact-form-mode-" + this.props.mode; + let contentAreaClassesLiteral = { + "content-area": true, + "contact-form": true + }; + contentAreaClassesLiteral[contactFormMode] = true; + let contentAreaClasses = cx(contentAreaClassesLiteral); return ( - React.createElement("div", {className: "content-area contact-form"}, + React.createElement("div", {className: contentAreaClasses}, React.createElement("header", null, this.props.mode == "add" - ? mozL10n.get("add_contact_button") + ? mozL10n.get("add_contact_title") : mozL10n.get("edit_contact_title")), - React.createElement("label", null, mozL10n.get("edit_contact_name_label")), - React.createElement("input", {className: cx({pristine: this.state.pristine}), - pattern: "\\s*\\S.*", - ref: "name", - required: true, - type: "text", - valueLink: this.linkState("name")}), - React.createElement("label", null, mozL10n.get("edit_contact_email_label")), - React.createElement("input", {className: cx({pristine: this.state.pristine}), - ref: "email", - required: phoneOrEmailRequired, - type: "email", - valueLink: this.linkState("email")}), - React.createElement("label", null, mozL10n.get("new_contact_fxos_phone_placeholder")), - React.createElement("input", {className: cx({pristine: this.state.pristine}), - ref: "tel", - required: phoneOrEmailRequired, - type: "tel", - valueLink: this.linkState("tel")}), + React.createElement("div", {className: cx({"form-content-container": true})}, + React.createElement("input", {className: cx({pristine: this.state.pristine}), + pattern: "\\s*\\S.*", + placeholder: mozL10n.get("contact_form_name_placeholder"), + ref: "name", + required: true, + type: "text", + valueLink: this.linkState("name")}), + React.createElement("input", {className: cx({pristine: this.state.pristine}), + placeholder: mozL10n.get("contact_form_email_placeholder"), + ref: "email", + required: phoneOrEmailRequired, + type: "email", + valueLink: this.linkState("email")}), + React.createElement("input", {className: cx({pristine: this.state.pristine}), + placeholder: mozL10n.get("contact_form_fxos_phone_placeholder"), + ref: "tel", + required: phoneOrEmailRequired, + type: "tel", + valueLink: this.linkState("tel")}) + ), React.createElement(ButtonGroup, null, React.createElement(Button, {additionalClass: "button-cancel", caption: mozL10n.get("cancel_button"), diff --git a/browser/components/loop/content/js/contacts.jsx b/browser/components/loop/content/js/contacts.jsx index 9780f1996bb5..6a2fb93656a8 100644 --- a/browser/components/loop/content/js/contacts.jsx +++ b/browser/components/loop/content/js/contacts.jsx @@ -740,31 +740,40 @@ loop.contacts = (function(_, mozL10n) { render: function() { let cx = React.addons.classSet; let phoneOrEmailRequired = !this.state.email && !this.state.tel; + let contactFormMode = "contact-form-mode-" + this.props.mode; + let contentAreaClassesLiteral = { + "content-area": true, + "contact-form": true + }; + contentAreaClassesLiteral[contactFormMode] = true; + let contentAreaClasses = cx(contentAreaClassesLiteral); return ( -
+
{this.props.mode == "add" - ? mozL10n.get("add_contact_button") + ? mozL10n.get("add_contact_title") : mozL10n.get("edit_contact_title")}
- - - - - - +
+ + + +
'; - content.document.title = "Style Inspector Search Filter Test"; - - info("Opening the computed-view"); - let {toolbox, inspector, view} = yield openComputedView(); - - info("Selecting the test node"); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openComputedView(); yield selectNode("#matches", inspector); - yield testToggleDefaultStyles(inspector, view); yield testAddTextInFilter(inspector, view); }); - function* testToggleDefaultStyles(inspector, computedView) { info("checking \"Browser styles\" checkbox"); - - let doc = computedView.styleDocument; let checkbox = computedView.includeBrowserStylesCheckbox; let onRefreshed = inspector.once("computed-view-refreshed"); checkbox.click(); @@ -39,8 +33,6 @@ function* testToggleDefaultStyles(inspector, computedView) { function* testAddTextInFilter(inspector, computedView) { info("setting filter text to \"color\""); - - let doc = computedView.styleDocument; let searchField = computedView.searchField; let onRefreshed = inspector.once("computed-view-refreshed"); searchField.focus(); diff --git a/browser/devtools/styleinspector/test/browser_computedview_search-filter_clear.js b/browser/devtools/styleinspector/test/browser_computedview_search-filter_clear.js index 04bd1856ec89..86df913806e8 100644 --- a/browser/devtools/styleinspector/test/browser_computedview_search-filter_clear.js +++ b/browser/devtools/styleinspector/test/browser_computedview_search-filter_clear.js @@ -6,18 +6,18 @@ // Tests that the search filter clear button works properly. -let TEST_URI = [ - '', - 'Some styled text' -].join("\n"); +const TEST_URI = ` + + Some styled text +`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openComputedView(); + let {inspector, view} = yield openComputedView(); yield selectNode("#matches", inspector); yield testAddTextInFilter(inspector, view); yield testClearSearchFilter(inspector, view); @@ -27,7 +27,6 @@ function* testAddTextInFilter(inspector, computedView) { info("Setting filter text to \"background-color\""); let win = computedView.styleWindow; - let doc = computedView.styleDocument; let propertyViews = computedView.propertyViews; let searchField = computedView.searchField; let checkbox = computedView.includeBrowserStylesCheckbox; @@ -53,7 +52,6 @@ function* testClearSearchFilter(inspector, computedView) { info("Clearing the search filter"); let win = computedView.styleWindow; - let doc = computedView.styleDocument; let propertyViews = computedView.propertyViews; let searchField = computedView.searchField; let searchClearButton = computedView.searchClearButton; diff --git a/browser/devtools/styleinspector/test/browser_computedview_search-filter_context-menu.js b/browser/devtools/styleinspector/test/browser_computedview_search-filter_context-menu.js index c5c15a3b1fc1..8e1794134f49 100644 --- a/browser/devtools/styleinspector/test/browser_computedview_search-filter_context-menu.js +++ b/browser/devtools/styleinspector/test/browser_computedview_search-filter_context-menu.js @@ -4,17 +4,15 @@ "use strict"; -// Test computed view search filter context menu works properly. +// Tests computed view search filter context menu works properly. const TEST_INPUT = "h1"; +const TEST_URI = "

test filter context menu

"; + add_task(function*() { - yield addTab("data:text/html;charset=utf-8,

test filter context menu

"); - - info("Opening the computed-view"); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {toolbox, inspector, view} = yield openComputedView(); - - info("Selecting the test node"); yield selectNode("h1", inspector); let win = view.styleWindow; diff --git a/browser/devtools/styleinspector/test/browser_computedview_search-filter_escape-keypress.js b/browser/devtools/styleinspector/test/browser_computedview_search-filter_escape-keypress.js index b85654a70dde..28887af90387 100644 --- a/browser/devtools/styleinspector/test/browser_computedview_search-filter_escape-keypress.js +++ b/browser/devtools/styleinspector/test/browser_computedview_search-filter_escape-keypress.js @@ -6,18 +6,18 @@ // Tests that search filter escape keypress will clear the search field. -let TEST_URI = [ - '', - 'Some styled text' -].join("\n"); +const TEST_URI = ` + + Some styled text +`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openComputedView(); + let {inspector, view} = yield openComputedView(); yield selectNode("#matches", inspector); yield testAddTextInFilter(inspector, view); yield testEscapeKeypress(inspector, view); diff --git a/browser/devtools/styleinspector/test/browser_computedview_select-and-copy-styles.js b/browser/devtools/styleinspector/test/browser_computedview_select-and-copy-styles.js index dc111c179b61..82aa095f835b 100644 --- a/browser/devtools/styleinspector/test/browser_computedview_select-and-copy-styles.js +++ b/browser/devtools/styleinspector/test/browser_computedview_select-and-copy-styles.js @@ -4,40 +4,42 @@ "use strict"; -// Tests that properties can be selected and copied from the computed view +// Tests that properties can be selected and copied from the computed view. XPCOMUtils.defineLazyGetter(this, "osString", function() { return Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS; }); +const TEST_URI = ` + +
+

Some header text

+

hi.

+

I am a test-case. This text exists + solely to provide some things to + highlight and count + style list-items in the box at right. If you are reading this, + you should go do something else instead. Maybe read a book. Or better + yet, write some test-cases for another bit of code. + some text

+

more text

+

even more text

+
+`; + add_task(function*() { - yield addTab("data:text/html;charset=utf-8,computed view copy test"); - - info("Creating the test document"); - content.document.body.innerHTML = '
\n' + - '

Some header text

\n' + - '

hi.

\n' + - '

I am a test-case. This text exists ' + - 'solely to provide some things to ' + - 'highlight and count ' + - 'style list-items in the box at right. If you are reading this, ' + - 'you should go do something else instead. Maybe read a book. Or better ' + - 'yet, write some test-cases for another bit of code. ' + - 'some text

\n' + - '

more text

\n' + - '

even more text

' + - '
'; - content.document.title = "Computed view context menu test"; - - info("Opening the computed view"); - let {toolbox, inspector, view} = yield openComputedView(); - - info("Selecting the test node"); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openComputedView(); yield selectNode("span", inspector); - yield checkCopySelection(view); yield checkSelectAll(view); }); @@ -54,7 +56,8 @@ function checkCopySelection(view) { range.setEnd(props[3], 3); contentDocument.defaultView.getSelection().addRange(range); - info("Checking that cssHtmlTree.siBoundCopy() returns the correct clipboard value"); + info("Checking that cssHtmlTree.siBoundCopy() returns the correct " + + "clipboard value"); let expectedPattern = "font-family: helvetica,sans-serif;[\\r\\n]+" + "font-size: 16px;[\\r\\n]+" + @@ -75,7 +78,8 @@ function checkSelectAll(view) { let contentDoc = view.styleDocument; let prop = contentDoc.querySelector(".property-view"); - info("Checking that _onSelectAll() then copy returns the correct clipboard value"); + info("Checking that _onSelectAll() then copy returns the correct " + + "clipboard value"); view._contextmenu._onSelectAll(); let expectedPattern = "color: #FF0;[\\r\\n]+" + "font-family: helvetica,sans-serif;[\\r\\n]+" + diff --git a/browser/devtools/styleinspector/test/browser_computedview_style-editor-link.js b/browser/devtools/styleinspector/test/browser_computedview_style-editor-link.js index 4a2ad240f188..e74e1aa0677e 100644 --- a/browser/devtools/styleinspector/test/browser_computedview_style-editor-link.js +++ b/browser/devtools/styleinspector/test/browser_computedview_style-editor-link.js @@ -11,14 +11,14 @@ // thisTestLeaksUncaughtRejectionsAndShouldBeFixed("Error: Unknown sheet source"); -// Test the links from the computed view to the style editor +// Tests the links from the computed view to the style editor. -const STYLESHEET_URL = "data:text/css,"+encodeURIComponent( +const STYLESHEET_URL = "data:text/css," + encodeURIComponent( [".highlight {", "color: blue", "}"].join("\n")); -const DOCUMENT_URL = "data:text/html;charset=utf-8,"+encodeURIComponent( +const DOCUMENT_URL = "data:text/html;charset=utf-8," + encodeURIComponent( ['' + '' + 'Computed view style editor link test', @@ -31,7 +31,7 @@ const DOCUMENT_URL = "data:text/html;charset=utf-8,"+encodeURIComponent( '', - '', + '', '', '', '

Some header text

', @@ -52,20 +52,16 @@ const DOCUMENT_URL = "data:text/html;charset=utf-8,"+encodeURIComponent( add_task(function*() { yield addTab(DOCUMENT_URL); - - info("Opening the computed-view"); let {toolbox, inspector, view} = yield openComputedView(); - - info("Selecting the test node"); yield selectNode("span", inspector); - yield testInlineStyle(view, inspector); + yield testInlineStyle(view); yield testFirstInlineStyleSheet(view, toolbox); yield testSecondInlineStyleSheet(view, toolbox); yield testExternalStyleSheet(view, toolbox); }); -function* testInlineStyle(view, inspector) { +function* testInlineStyle(view) { info("Testing inline style"); yield expandComputedViewPropertyByIndex(view, 0); @@ -111,7 +107,8 @@ function* testSecondInlineStyleSheet(view, toolbox) { clickLinkByIndex(view, 4); let editor = yield onSelected; - is(toolbox.currentToolId, "styleeditor", "The style editor is selected again"); + is(toolbox.currentToolId, "styleeditor", + "The style editor is selected again"); validateStyleEditorSheet(editor, 1); } @@ -129,14 +126,16 @@ function* testExternalStyleSheet(view, toolbox) { clickLinkByIndex(view, 1); let editor = yield onSelected; - is(toolbox.currentToolId, "styleeditor", "The style editor is selected again"); + is(toolbox.currentToolId, "styleeditor", + "The style editor is selected again"); validateStyleEditorSheet(editor, 2); } function validateStyleEditorSheet(editor, expectedSheetIndex) { info("Validating style editor stylesheet"); let sheet = content.document.styleSheets[expectedSheetIndex]; - is(editor.styleSheet.href, sheet.href, "loaded stylesheet matches document stylesheet"); + is(editor.styleSheet.href, sheet.href, + "loaded stylesheet matches document stylesheet"); } function clickLinkByIndex(view, index) { diff --git a/browser/devtools/styleinspector/test/browser_ruleview_add-property-and-reselect.js b/browser/devtools/styleinspector/test/browser_ruleview_add-property-and-reselect.js index 03a45e4c6537..08d5fc056a26 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_add-property-and-reselect.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_add-property-and-reselect.js @@ -5,16 +5,13 @@ "use strict"; // Tests that adding properties to rules work and reselecting the element still -// show them +// show them. const TEST_URI = TEST_URL_ROOT + "doc_content_stylesheet.html"; add_task(function*() { yield addTab(TEST_URI); - - let target = getNode("#target"); - - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#target", inspector); info("Setting a font-weight property on all rules"); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_01.js b/browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_01.js index 27e38b17cde4..97106c09f7f7 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_01.js @@ -4,19 +4,19 @@ "use strict"; -// Tests adding a new property and escapes the new empty property name editor +// Tests adding a new property and escapes the new empty property name editor. -let TEST_URI = [ - "", - "
Styled Node
" -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_02.js b/browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_02.js index 330493bbaf08..36f4574cc9b7 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_02.js @@ -4,16 +4,16 @@ "use strict"; -// Tests adding a new property and escapes the new empty property value editor +// Tests adding a new property and escapes the new empty property value editor. -let TEST_URI = [ - "", - "
Styled Node
" -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_03.js b/browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_03.js index d9863b27e786..f4d0e3de9729 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_03.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_03.js @@ -4,19 +4,20 @@ "use strict"; -// Tests adding a new property and escapes the property name editor with a value +// Tests adding a new property and escapes the property name editor with a +// value. -let TEST_URI = [ - "", - "
Styled Node
" -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_add-property-svg.js b/browser/devtools/styleinspector/test/browser_ruleview_add-property-svg.js index 27379244601c..fe384c51d0a2 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_add-property-svg.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_add-property-svg.js @@ -4,20 +4,15 @@ "use strict"; -// Tests editing SVG styles using the rules view +// Tests editing SVG styles using the rules view. let TEST_URL = "chrome://global/skin/icons/warning.svg"; let TEST_SELECTOR = "path"; add_task(function*() { yield addTab(TEST_URL); - - info("Opening the rule-view"); - let {toolbox, inspector, view} = yield openRuleView(); - - info("Selecting the test element"); + let {inspector, view} = yield openRuleView(); yield selectNode(TEST_SELECTOR, inspector); - yield testCreateNew(view); }); @@ -45,10 +40,13 @@ function* testCreateNew(ruleView) { editor = inplaceEditor(ruleView.styleDocument.activeElement); - is(elementRuleEditor.rule.textProps.length, 1, "Should have created a new text property."); - is(elementRuleEditor.propertyList.children.length, 1, "Should have created a property editor."); + is(elementRuleEditor.rule.textProps.length, 1, + "Should have created a new text property."); + is(elementRuleEditor.propertyList.children.length, 1, + "Should have created a property editor."); let textProp = elementRuleEditor.rule.textProps[0]; - is(editor, inplaceEditor(textProp.editor.valueSpan), "Should be editing the value span now."); + is(editor, inplaceEditor(textProp.editor.valueSpan), + "Should be editing the value span now."); editor.input.value = "red"; let onBlur = once(editor.input, "blur"); @@ -58,5 +56,6 @@ function* testCreateNew(ruleView) { is(textProp.value, "red", "Text prop should have been changed."); - is((yield getComputedStyleProperty(TEST_SELECTOR, null, "fill")), "rgb(255, 0, 0)", "The fill was changed to red"); + is((yield getComputedStyleProperty(TEST_SELECTOR, null, "fill")), + "rgb(255, 0, 0)", "The fill was changed to red"); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_add-property_01.js b/browser/devtools/styleinspector/test/browser_ruleview_add-property_01.js index d720f8479757..f543a152244f 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_add-property_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_add-property_01.js @@ -8,31 +8,22 @@ // FIXME: To be split in several test files, and some of the inplace-editor // focus/blur/commit/revert stuff should be factored out in head.js -let TEST_URL = 'url("' + TEST_URL_ROOT + 'doc_test_image.png")'; -let PAGE_CONTENT = [ - '', - '
Styled Node
' -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,test rule view user changes"); - - info("Creating the test document"); - content.document.body.innerHTML = PAGE_CONTENT; - - info("Opening the rule-view"); - let {toolbox, inspector, view} = yield openRuleView(); - - info("Selecting the test element"); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); - yield testCreateNew(view); }); @@ -44,7 +35,8 @@ function* testCreateNew(view) { info("Focusing a new property name in the rule-view"); let editor = yield focusEditableField(view, elementRuleEditor.closeBrace); - is(inplaceEditor(elementRuleEditor.newPropSpan), editor, "The new property editor got focused"); + is(inplaceEditor(elementRuleEditor.newPropSpan), editor, + "The new property editor got focused"); let input = editor.input; info("Entering background-color in the property name editor"); @@ -61,9 +53,12 @@ function* testCreateNew(view) { editor = inplaceEditor(view.styleDocument.activeElement); let textProp = elementRuleEditor.rule.textProps[0]; - is(elementRuleEditor.rule.textProps.length, 1, "Created a new text property."); - is(elementRuleEditor.propertyList.children.length, 1, "Created a property editor."); - is(editor, inplaceEditor(textProp.editor.valueSpan), "Editing the value span now."); + is(elementRuleEditor.rule.textProps.length, 1, + "Created a new text property."); + is(elementRuleEditor.propertyList.children.length, 1, + "Created a property editor."); + is(editor, inplaceEditor(textProp.editor.valueSpan), + "Editing the value span now."); info("Entering a value and bluring the field to expect a rule change"); editor.input.value = "#XYZ"; diff --git a/browser/devtools/styleinspector/test/browser_ruleview_add-property_02.js b/browser/devtools/styleinspector/test/browser_ruleview_add-property_02.js index 45ff3ef857e5..9c971426348a 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_add-property_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_add-property_02.js @@ -4,25 +4,25 @@ "use strict"; -// Test all sorts of additions and updates of properties in the rule-view +// Tests all sorts of additions and updates of properties in the rule-view. // FIXME: TO BE SPLIT IN *MANY* SMALLER TESTS +const TEST_URI = ` + +
Styled Node
+
Styled Node
+`; + add_task(function*() { - yield addTab("data:text/html;charset=utf-8,browser_ruleview_ui.js"); - let {toolbox, inspector, view} = yield openRuleView(); - - info("Creating the test document"); - let style = "" + - "#testid {" + - " background-color: blue;" + - "}" + - ".testclass, .unmatched {" + - " background-color: green;" + - "}"; - let styleNode = addStyle(content.document, style); - content.document.body.innerHTML = "
Styled Node
" + - "
Styled Node
"; - + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield testCreateNew(inspector, view); }); @@ -39,7 +39,8 @@ function* testCreateNew(inspector, ruleView) { ok(input.selectionStart === 0 && input.selectionEnd === input.value.length, "Editor contents are selected."); - // Try clicking on the editor's input again, shouldn't cause trouble (see bug 761665). + // Try clicking on the editor's input again, shouldn't cause trouble + // (see bug 761665). EventUtils.synthesizeMouse(input, 1, 1, {}, ruleView.styleWindow); input.select(); @@ -54,10 +55,13 @@ function* testCreateNew(inspector, ruleView) { editor = inplaceEditor(ruleView.styleDocument.activeElement); - is(elementRuleEditor.rule.textProps.length, 1, "Should have created a new text property."); - is(elementRuleEditor.propertyList.children.length, 1, "Should have created a property editor."); + is(elementRuleEditor.rule.textProps.length, 1, + "Should have created a new text property."); + is(elementRuleEditor.propertyList.children.length, 1, + "Should have created a property editor."); let textProp = elementRuleEditor.rule.textProps[0]; - is(editor, inplaceEditor(textProp.editor.valueSpan), "Should be editing the value span now."); + is(editor, inplaceEditor(textProp.editor.valueSpan), + "Should be editing the value span now."); let onMutated = inspector.once("markupmutation"); editor.input.value = "purple"; diff --git a/browser/devtools/styleinspector/test/browser_ruleview_add-rule_01.js b/browser/devtools/styleinspector/test/browser_ruleview_add-rule_01.js index 1b5b20d1b8f2..66eaf8fd24c1 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_add-rule_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_add-rule_01.js @@ -5,22 +5,22 @@ "use strict"; // Tests the behaviour of adding a new rule to the rule view and the -// various inplace-editor behaviours in the new rule editor +// various inplace-editor behaviours in the new rule editor. -let PAGE_CONTENT = [ - '', - '
Styled Node
', - 'This is a span', - 'Multiple classes', - 'Multiple classes', - '

Empty

', - '

Invalid characters in class

', - '

Invalid characters in id

' -].join("\n"); +const TEST_URI = ` + +
Styled Node
+ This is a span + Multiple classes + Multiple classes +

Empty

+

Invalid characters in class

+

Invalid characters in id

+`; const TEST_DATA = [ { node: "#testid", expected: "#testid" }, @@ -33,12 +33,9 @@ const TEST_DATA = [ ]; add_task(function*() { - yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(PAGE_CONTENT)); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); - info("Opening the rule-view"); - let {toolbox, inspector, view} = yield openRuleView(); - - info("Iterating over the test data"); for (let data of TEST_DATA) { yield runTestData(inspector, view, data, "context-menu"); yield runTestData(inspector, view, data, "button"); @@ -47,15 +44,12 @@ add_task(function*() { function* runTestData(inspector, view, data, method) { let {node, expected} = data; - info("Selecting the test element"); yield selectNode(node, inspector); - yield addNewRule(inspector, view, method); - yield testNewRule(view, expected, 1); info("Resetting page content"); - content.document.body.innerHTML = PAGE_CONTENT; + content.document.body.innerHTML = TEST_URI; } function* addNewRule(inspector, view, method) { @@ -73,11 +67,11 @@ function* addNewRule(inspector, view, method) { info("Adding the new rule"); view._contextmenu.menuitemAddRule.click(); view._contextmenu._menupopup.hidePopup(); - } - else { + } else { info("Adding the new rule using the button"); view.addRuleButton.click(); } + info("Waiting for rule view to change"); yield view.once("ruleview-changed"); } @@ -94,7 +88,7 @@ function* testNewRule(view, expected, index) { is(idRuleEditor.selectorText.textContent, expected, "Selector text value is as expected: " + expected); - info("Adding new properties to new rule: " + expected) + info("Adding new properties to new rule: " + expected); let onRuleViewChanged = view.once("ruleview-changed"); idRuleEditor.addProperty("font-weight", "bold", ""); yield onRuleViewChanged; diff --git a/browser/devtools/styleinspector/test/browser_ruleview_add-rule_02.js b/browser/devtools/styleinspector/test/browser_ruleview_add-rule_02.js index 1c38c45e719e..5d32438aaa32 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_add-rule_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_add-rule_02.js @@ -5,33 +5,25 @@ "use strict"; // Tests the behaviour of adding a new rule to the rule view and editing -// its selector +// its selector. -let PAGE_CONTENT = [ - '', - '
Styled Node
', - 'This is a span' -].join("\n"); +const TEST_URI = ` + +
Styled Node
+ This is a span +`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(PAGE_CONTENT)); - - info("Opening the rule-view"); - let {toolbox, inspector, view} = yield openRuleView(); - - info("Selecting the test element"); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); - info("Waiting for rule view to update"); let onRuleViewChanged = once(view, "ruleview-changed"); - - info("Adding the new rule"); view.addRuleButton.click(); - yield onRuleViewChanged; yield testEditSelector(view, "span"); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_add-rule_03.js b/browser/devtools/styleinspector/test/browser_ruleview_add-rule_03.js index 7c8055e98caf..12cef69a64c3 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_add-rule_03.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_add-rule_03.js @@ -5,33 +5,25 @@ "use strict"; // Tests the behaviour of adding a new rule to the rule view, adding a new -// property and editing the selector +// property and editing the selector. -let PAGE_CONTENT = [ - '', - '
Styled Node
', - 'This is a span' -].join("\n"); +const TEST_URI = ` + +
Styled Node
+ This is a span +`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(PAGE_CONTENT)); - - info("Opening the rule-view"); - let {toolbox, inspector, view} = yield openRuleView(); - - info("Selecting the test element"); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); - info("Waiting for rule view to change"); let onRuleViewChanged = once(view, "ruleview-changed"); - - info("Adding the new rule"); view.addRuleButton.click(); - yield onRuleViewChanged; info("Adding new properties to the new rule"); @@ -59,7 +51,7 @@ function* testNewRule(view, expected, index) { is(idRuleEditor.selectorText.textContent, expected, "Selector text value is as expected: " + expected); - info("Adding new properties to new rule: " + expected) + info("Adding new properties to new rule: " + expected); idRuleEditor.addProperty("font-weight", "bold", ""); let textProps = idRuleEditor.rule.textProps; let lastRule = textProps[textProps.length - 1]; diff --git a/browser/devtools/styleinspector/test/browser_ruleview_add-rule_04.js b/browser/devtools/styleinspector/test/browser_ruleview_add-rule_04.js index 479a572a9c52..09767562ff38 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_add-rule_04.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_add-rule_04.js @@ -5,24 +5,21 @@ "use strict"; // Tests if the `Add rule` button disables itself properly for non-element nodes -// and anonymous element +// and anonymous element. -let PAGE_CONTENT = ` +const TEST_URI = `
-
Test Node
`; +
Test Node
+`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(PAGE_CONTENT)); - - info("Opening the rule-view"); - let {toolbox, inspector, view} = yield openRuleView(); - - info("Running test"); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield testDisabledButton(inspector, view); }); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_add-rule_pseudo_class.js b/browser/devtools/styleinspector/test/browser_ruleview_add-rule_pseudo_class.js index 67c3d7e01e74..2b64aabcc76e 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_add-rule_pseudo_class.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_add-rule_pseudo_class.js @@ -4,9 +4,9 @@ "use strict"; -// Tests adding a rule with pseudo class locks on +// Tests adding a rule with pseudo class locks on. -let PAGE_CONTENT = "

Test element

"; +const TEST_URI = "

Test element

"; const EXPECTED_SELECTOR = "#element"; const TEST_DATA = [ @@ -20,15 +20,10 @@ const TEST_DATA = [ ]; add_task(function*() { - yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(PAGE_CONTENT)); - - info("Opening the rule-view"); - let {toolbox, inspector, view} = yield openRuleView(); - - info("Selecting the test element"); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("#element", inspector); - info("Iterating over the test data"); for (let data of TEST_DATA) { yield runTestData(inspector, view, data); } @@ -68,7 +63,8 @@ function* setPseudoLocks(inspector, view, pseudoClasses) { if (pseudoClasses.length == 0) { return; } - for (var pseudoClass of pseudoClasses) { + + for (let pseudoClass of pseudoClasses) { switch (pseudoClass) { case ":hover": view.hoverCheckbox.click(); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-and-image-tooltip_01.js b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-and-image-tooltip_01.js index 07df4d898304..86cf55079f44 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-and-image-tooltip_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-and-image-tooltip_01.js @@ -4,24 +4,22 @@ "use strict"; -// Test that after a color change, the image preview tooltip in the same +// Tests that after a color change, the image preview tooltip in the same // property is displayed and positioned correctly. // See bug 979292 -const PAGE_CONTENT = [ - '', - 'Testing the color picker tooltip!' -].join("\n"); +const TEST_URI = ` + + Testing the color picker tooltip! +`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,rule view color picker tooltip test"); - content.document.body.innerHTML = PAGE_CONTENT; - let {toolbox, inspector, view} = yield openRuleView(); - + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {view} = yield openRuleView(); let value = getRuleViewProperty(view, "body", "background").valueSpan; let swatch = value.querySelectorAll(".ruleview-colorswatch")[1]; let url = value.querySelector(".theme-link"); @@ -30,7 +28,8 @@ add_task(function*() { function* testImageTooltipAfterColorChange(swatch, url, ruleView) { info("First, verify that the image preview tooltip works"); - let anchor = yield isHoverTooltipTarget(ruleView.tooltips.previewTooltip, url); + let anchor = yield isHoverTooltipTarget(ruleView.tooltips.previewTooltip, + url); ok(anchor, "The image preview tooltip is shown on the url span"); is(anchor, url, "The anchor returned by the showOnHover callback is correct"); @@ -53,7 +52,8 @@ function* testImageTooltipAfterColorChange(swatch, url, ruleView) { info("Verify again that the image preview tooltip works"); // After a color change, the property is re-populated, we need to get the new // dom node - url = getRuleViewProperty(ruleView, "body", "background").valueSpan.querySelector(".theme-link"); + url = getRuleViewProperty(ruleView, "body", "background").valueSpan + .querySelector(".theme-link"); anchor = yield isHoverTooltipTarget(ruleView.tooltips.previewTooltip, url); ok(anchor, "The image preview tooltip is shown on the url span"); is(anchor, url, "The anchor returned by the showOnHover callback is correct"); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-and-image-tooltip_02.js b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-and-image-tooltip_02.js index 9a017edcef46..2fdcc379b9c9 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-and-image-tooltip_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-and-image-tooltip_02.js @@ -4,25 +4,29 @@ "use strict"; -// Test that after a color change, opening another tooltip, like the image -// preview doesn't revert the color change in the ruleView. +// Tests that after a color change, opening another tooltip, like the image +// preview doesn't revert the color change in the rule view. // This used to happen when the activeSwatch wasn't reset when the colorpicker // would hide. // See bug 979292 +const TEST_URI = ` + + Testing the color picker tooltip! +`; + const PAGE_CONTENT = [ - '', - 'Testing the color picker tooltip!' + ].join("\n"); add_task(function*() { - yield addTab("data:text/html;charset=utf-8,rule view color picker tooltip test"); - content.document.body.innerHTML = PAGE_CONTENT; - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {view} = yield openRuleView(); yield testColorChangeIsntRevertedWhenOtherTooltipIsShown(view); }); @@ -50,12 +54,14 @@ function* testColorChangeIsntRevertedWhenOtherTooltipIsShown(ruleView) { let value = getRuleViewProperty(ruleView, "body", "background").valueSpan; let url = value.querySelector(".theme-link"); onShown = ruleView.tooltips.previewTooltip.once("shown"); - let anchor = yield isHoverTooltipTarget(ruleView.tooltips.previewTooltip, url); + let anchor = yield isHoverTooltipTarget(ruleView.tooltips.previewTooltip, + url); ruleView.tooltips.previewTooltip.show(anchor); yield onShown; info("Image tooltip is shown, verify that the swatch is still correct"); swatch = value.querySelector(".ruleview-colorswatch"); - is(swatch.style.backgroundColor, "rgb(0, 0, 0)", "The swatch's color is correct"); + is(swatch.style.backgroundColor, "rgb(0, 0, 0)", + "The swatch's color is correct"); is(swatch.nextSibling.textContent, "#000", "The color name is correct"); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-appears-on-swatch-click.js b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-appears-on-swatch-click.js index 806b35f090da..fca90088470d 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-appears-on-swatch-click.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-appears-on-swatch-click.js @@ -4,24 +4,23 @@ "use strict"; -// Test that color pickers appear when clicking on color swatches +// Tests that color pickers appear when clicking on color swatches. -const PAGE_CONTENT = [ - '', - 'Testing the color picker tooltip!' -].join("\n"); +const TEST_URI = ` + + Testing the color picker tooltip! +`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,rule view color picker tooltip test"); - content.document.body.innerHTML = PAGE_CONTENT; - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {view} = yield openRuleView(); let cSwatch = getRuleViewProperty(view, "body", "color").valueSpan .querySelector(".ruleview-colorswatch"); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-commit-on-ENTER.js b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-commit-on-ENTER.js index cfa5233e5605..21213a6f3201 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-commit-on-ENTER.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-commit-on-ENTER.js @@ -4,23 +4,23 @@ "use strict"; -// Test that a color change in the color picker is committed when ENTER is pressed +// Tests that a color change in the color picker is committed when ENTER is +// pressed. -const PAGE_CONTENT = [ - '', - 'Testing the color picker tooltip!' -].join("\n"); +const TEST_URI = ` + + Testing the color picker tooltip! +`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,rule view color picker tooltip test"); - content.document.body.innerHTML = PAGE_CONTENT; - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {view} = yield openRuleView(); - let swatch = getRuleViewProperty(view, "body" , "border").valueSpan + let swatch = getRuleViewProperty(view, "body", "border").valueSpan .querySelector(".ruleview-colorswatch"); yield testPressingEnterCommitsChanges(swatch, view); }); @@ -42,7 +42,7 @@ function* testPressingEnterCommitsChanges(swatch, ruleView) { "The color swatch's background was updated"); is(getRuleViewProperty(ruleView, "body", "border").valueSpan.textContent, "2em solid rgba(0, 255, 0, 0.5)", - "The text of the border css property was updated");; + "The text of the border css property was updated"); let spectrum = yield cPicker.spectrum; let onHidden = cPicker.tooltip.once("hidden"); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-edit-gradient.js b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-edit-gradient.js index ee5bbba7f70e..6e24c9cf9b07 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-edit-gradient.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-edit-gradient.js @@ -4,26 +4,21 @@ "use strict"; -// Test that changing a color in a gradient css declaration using the tooltip -// color picker works +// Tests that changing a color in a gradient css declaration using the tooltip +// color picker works. -const PAGE_CONTENT = [ - '', - 'Updating a gradient declaration with the color picker tooltip' -].join("\n"); +const TEST_URI = ` + + Updating a gradient declaration with the color picker tooltip +`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,rule view color picker tooltip test"); - - info("Creating the test document"); - content.document.body.innerHTML = PAGE_CONTENT; - - info("Opening the rule-view") - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {view} = yield openRuleView(); info("Testing that the colors in gradient properties are parsed correctly"); testColorParsing(view); @@ -45,7 +40,7 @@ function testColorParsing(view) { is(colorEls.length, 3, "There are 3 color values"); let colors = ["#F06", "#333", "#000"]; - for (let i = 0; i < colors.length; i ++) { + for (let i = 0; i < colors.length; i++) { is(colorEls[i].textContent, colors[i], "The right color value was found"); } } @@ -73,7 +68,8 @@ function* testPickingNewColor(view) { "The color swatch's background was updated"); is(colorEl.textContent, "#010101", "The color text was updated"); is(content.getComputedStyle(content.document.body).backgroundImage, - "linear-gradient(to left, rgb(1, 1, 1) 25%, rgb(51, 51, 51) 95%, rgb(0, 0, 0) 100%)", + "linear-gradient(to left, rgb(1, 1, 1) 25%, rgb(51, 51, 51) 95%, " + + "rgb(0, 0, 0) 100%)", "The gradient has been updated correctly"); cPicker.hide(); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-hides-on-tooltip.js b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-hides-on-tooltip.js index 369378082302..bf50837db0f3 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-hides-on-tooltip.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-hides-on-tooltip.js @@ -4,24 +4,23 @@ "use strict"; -// Test that the color picker tooltip hides when an image tooltip appears +// Tests that the color picker tooltip hides when an image tooltip appears. -const PAGE_CONTENT = [ - '', - 'Testing the color picker tooltip!' -].join("\n"); +const TEST_URI = ` + + Testing the color picker tooltip! +`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,rule view color picker tooltip test"); - content.document.body.innerHTML = PAGE_CONTENT; - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {view} = yield openRuleView(); let swatch = getRuleViewProperty(view, "body", "color").valueSpan .querySelector(".ruleview-colorswatch"); @@ -30,7 +29,8 @@ add_task(function*() { }); function* testColorPickerHidesWhenImageTooltipAppears(view, swatch) { - let bgImageSpan = getRuleViewProperty(view, "body", "background-image").valueSpan; + let bgImageSpan = getRuleViewProperty(view, "body", "background-image") + .valueSpan; let uriSpan = bgImageSpan.querySelector(".theme-link"); let tooltip = view.tooltips.colorPicker.tooltip; diff --git a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-multiple-changes.js b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-multiple-changes.js index d52c03a73e71..58a374f7d56c 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-multiple-changes.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-multiple-changes.js @@ -4,30 +4,30 @@ "use strict"; -// Test that the color in the colorpicker tooltip can be changed several times +// Tests that the color in the colorpicker tooltip can be changed several times. // without causing error in various cases: // - simple single-color property (color) // - color and image property (background-image) // - overridden property // See bug 979292 and bug 980225 -const PAGE_CONTENT = [ - '', - '

Testing the color picker tooltip!

' -].join("\n"); +const TEST_URI = ` + +

Testing the color picker tooltip!

+`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,rule view color picker tooltip test"); - content.document.body.innerHTML = PAGE_CONTENT; - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield testSimpleMultipleColorChanges(inspector, view); yield testComplexMultipleColorChanges(inspector, view); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-release-outside-frame.js b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-release-outside-frame.js index b86428280f27..8e6c2e9f99ba 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-release-outside-frame.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-release-outside-frame.js @@ -4,15 +4,14 @@ "use strict"; -// Test that color pickers stops following the pointer if the pointer is +// Tests that color pickers stops following the pointer if the pointer is // released outside the tooltip frame (bug 1160720). -const PAGE_CONTENT = "data:text/html;charset=utf-8," + - 'Test page for bug 1160720'; +const TEST_URI = "Test page for bug 1160720"; add_task(function*() { - yield addTab(PAGE_CONTENT); - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {view} = yield openRuleView(); let cSwatch = getRuleViewProperty(view, "element", "color").valueSpan .querySelector(".ruleview-colorswatch"); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-revert-on-ESC.js b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-revert-on-ESC.js index 7ac2b0156e3e..fbdd4e41300f 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-revert-on-ESC.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-revert-on-ESC.js @@ -4,15 +4,16 @@ "use strict"; -// Test that a color change in the color picker is reverted when ESC is pressed +// Tests that a color change in the color picker is reverted when ESC is +// pressed. -let TEST_URI = [ - "", -].join("\n"); +const TEST_URI = ` + +`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-swatch-displayed.js b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-swatch-displayed.js index 56b94a4636e7..98296ad33565 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-swatch-displayed.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_colorpicker-swatch-displayed.js @@ -4,25 +4,25 @@ "use strict"; -// Test that color swatches are displayed next to colors in the rule-view +// Tests that color swatches are displayed next to colors in the rule-view. -const PAGE_CONTENT = [ - '', - 'Testing the color picker tooltip!' -].join("\n"); +const TEST_URI = ` + + Testing the color picker tooltip! +`; -// Tests that properties in the rule-view contain color swatches +// Tests that properties in the rule-view contain color swatches. // Each entry in the test array should contain: // { // selector: the rule-view selector to look for the property in @@ -38,9 +38,8 @@ const TESTS = [ ]; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,rule view color picker tooltip test"); - content.document.body.innerHTML = PAGE_CONTENT; - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {view} = yield openRuleView(); for (let {selector, propertyName, nb} of TESTS) { info("Looking for color swatches in property " + propertyName + diff --git a/browser/devtools/styleinspector/test/browser_ruleview_completion-existing-property_01.js b/browser/devtools/styleinspector/test/browser_ruleview_completion-existing-property_01.js index 683c6776fe74..d6f08f6504cc 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_completion-existing-property_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_completion-existing-property_01.js @@ -4,8 +4,8 @@ "use strict"; -// Test that CSS property names are autocompleted and cycled correctly when -// editing an existing property in the rule view +// Tests that CSS property names are autocompleted and cycled correctly when +// editing an existing property in the rule view. const MAX_ENTRIES = 10; @@ -18,8 +18,8 @@ const MAX_ENTRIES = 10; // ] let testData = [ ["VK_RIGHT", "font", -1, 0], - ["-","font-family", 0, MAX_ENTRIES], - ["f","font-family", 0, 2], + ["-", "font-family", 0, MAX_ENTRIES], + ["f", "font-family", 0, 2], ["VK_BACK_SPACE", "font-f", -1, 0], ["VK_BACK_SPACE", "font-", -1, 0], ["VK_BACK_SPACE", "font", -1, 0], @@ -54,11 +54,10 @@ let testData = [ ["VK_ESCAPE", null, -1, 0], ]; -let TEST_URL = "data:text/html;charset=utf-8,

Filename" + - ": browser_bug893965_css_property_completion_existing_property.js

"; +const TEST_URI = "

Header

"; add_task(function*() { - yield addTab(TEST_URL); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {toolbox, inspector, view} = yield openRuleView(); info("Test autocompletion after 1st page load"); @@ -74,7 +73,8 @@ function* runAutocompletionTest(toolbox, inspector, view) { yield selectNode("h1", inspector); info("Focusing the css property editable field"); - let propertyName = view.styleDocument.querySelectorAll(".ruleview-propertyname")[0]; + let propertyName = view.styleDocument + .querySelectorAll(".ruleview-propertyname")[0]; let editor = yield focusEditableField(view, propertyName); info("Starting to test for css property completion"); @@ -90,7 +90,8 @@ function* testCompletion([key, completion, index, total], editor, view) { let onSuggest; if (/(left|right|back_space|escape|home|end|page_up|page_down)/ig.test(key)) { - info("Adding event listener for left|right|back_space|escape|home|end|page_up|page_down keys"); + info("Adding event listener for " + + "left|right|back_space|escape|home|end|page_up|page_down keys"); onSuggest = once(editor.input, "keypress"); } else { info("Waiting for after-suggest event on the editor"); @@ -110,7 +111,8 @@ function* testCompletion([key, completion, index, total], editor, view) { 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"); + 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"); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_completion-existing-property_02.js b/browser/devtools/styleinspector/test/browser_ruleview_completion-existing-property_02.js index 035be57dd33a..e41c2cb6277e 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_completion-existing-property_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_completion-existing-property_02.js @@ -4,8 +4,8 @@ "use strict"; -// Test that CSS property names and values are autocompleted and cycled correctly -// when editing existing properties in the rule view +// Tests that CSS property names and values are autocompleted and cycled +// correctly when editing existing properties in the rule view. // format : // [ @@ -36,11 +36,10 @@ let testData = [ ["VK_RETURN", {}, null, -1, 0] ]; -let TEST_URL = "data:text/html;charset=utf-8,

Filename: " + - "browser_bug894376_css_value_completion_existing_property_value_pair.js

"; +const TEST_URI = "

Header

"; add_task(function*() { - yield addTab(TEST_URL); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {toolbox, inspector, view} = yield openRuleView(); info("Test autocompletion after 1st page load"); @@ -68,7 +67,8 @@ function* runAutocompletionTest(toolbox, inspector, view) { } } -function* testCompletion([key, modifiers, completion, index, total], editor, view) { +function* testCompletion([key, modifiers, completion, index, total], editor, + view) { info("Pressing key " + key); info("Expecting " + completion + ", " + index + ", " + total); @@ -103,7 +103,8 @@ function* testCompletion([key, modifiers, completion, index, total], editor, vie 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"); + 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"); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_completion-new-property_01.js b/browser/devtools/styleinspector/test/browser_ruleview_completion-new-property_01.js index 6be099827f9d..26be708eaf1d 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_completion-new-property_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_completion-new-property_01.js @@ -4,8 +4,8 @@ "use strict"; -// Test that CSS property names are autocompleted and cycled correctly when -// creating a new property in the ruleview +// Tests that CSS property names are autocompleted and cycled correctly when +// creating a new property in the rule view. const MAX_ENTRIES = 10; @@ -37,11 +37,10 @@ let testData = [ ["VK_ESCAPE", null, -1, 0], ]; -let TEST_URL = "data:text/html;charset=utf-8,

Filename:" + - "browser_bug893965_css_property_completion_new_property.js

"; +const TEST_URI = "

Header

"; add_task(function*() { - yield addTab(TEST_URL); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {toolbox, inspector, view} = yield openRuleView(); info("Test autocompletion after 1st page load"); @@ -93,7 +92,8 @@ function* testCompletion([key, completion, index, total], editor, view) { 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"); + 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"); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_completion-new-property_02.js b/browser/devtools/styleinspector/test/browser_ruleview_completion-new-property_02.js index ff9df05b3280..9267981c5769 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_completion-new-property_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_completion-new-property_02.js @@ -4,8 +4,8 @@ "use strict"; -// Test that CSS property names and values are autocompleted and cycled correctly -// when editing new properties in the rule view +// Tests that CSS property names and values are autocompleted and cycled +// correctly when editing new properties in the rule view. // format : // [ @@ -39,11 +39,17 @@ let testData = [ ["VK_ESCAPE", {}, null, -1, 0] ]; -let TEST_URL = "data:text/html;charset=utf-8," + - "

Test element

"; +const TEST_URI = ` + +

Test element

+`; add_task(function*() { - yield addTab(TEST_URL); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {toolbox, inspector, view} = yield openRuleView(); info("Test autocompletion after 1st page load"); @@ -63,7 +69,7 @@ function* runAutocompletionTest(toolbox, inspector, view) { let editor = yield focusEditableField(view, brace); info("Starting to test for css property completion"); - for (let i = 0; i < testData.length; i ++) { + 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.styleDocument.activeElement); @@ -71,7 +77,8 @@ function* runAutocompletionTest(toolbox, inspector, view) { } } -function* testCompletion([key, modifiers, completion, index, total], editor, view) { +function* testCompletion([key, modifiers, completion, index, total], editor, + view) { info("Pressing key " + key); info("Expecting " + completion + ", " + index + ", " + total); @@ -106,7 +113,8 @@ function* testCompletion([key, modifiers, completion, index, total], editor, vie 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"); + 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"); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_completion-popup-hidden-after-navigation.js b/browser/devtools/styleinspector/test/browser_ruleview_completion-popup-hidden-after-navigation.js index 978df7c04920..3b458a75328d 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_completion-popup-hidden-after-navigation.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_completion-popup-hidden-after-navigation.js @@ -4,12 +4,12 @@ "use strict"; -// Test that the ruleview autocomplete popup is hidden after page navigation +// Tests that the ruleview autocomplete popup is hidden after page navigation. -let TEST_URL = "data:text/html;charset=utf-8,

"; +const TEST_URI = "

"; add_task(function*() { - yield addTab(TEST_URL); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); info("Test autocompletion popup is hidden after page navigation"); @@ -18,7 +18,8 @@ add_task(function*() { yield selectNode("h1", inspector); info("Focusing the css property editable field"); - let propertyName = view.styleDocument.querySelectorAll(".ruleview-propertyname")[0]; + let propertyName = view.styleDocument + .querySelectorAll(".ruleview-propertyname")[0]; let editor = yield focusEditableField(view, propertyName); info("Pressing key VK_DOWN"); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_computed_01.js b/browser/devtools/styleinspector/test/browser_ruleview_computed-lists_01.js similarity index 100% rename from browser/devtools/styleinspector/test/browser_ruleview_computed_01.js rename to browser/devtools/styleinspector/test/browser_ruleview_computed-lists_01.js diff --git a/browser/devtools/styleinspector/test/browser_ruleview_computed_02.js b/browser/devtools/styleinspector/test/browser_ruleview_computed-lists_02.js similarity index 100% rename from browser/devtools/styleinspector/test/browser_ruleview_computed_02.js rename to browser/devtools/styleinspector/test/browser_ruleview_computed-lists_02.js diff --git a/browser/devtools/styleinspector/test/browser_ruleview_context-menu-show-mdn-docs-01.js b/browser/devtools/styleinspector/test/browser_ruleview_context-menu-show-mdn-docs-01.js index a090800ca5bc..63b0d5c926ad 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_context-menu-show-mdn-docs-01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_context-menu-show-mdn-docs-01.js @@ -23,31 +23,29 @@ const {setBaseCssDocsUrl} = require("devtools/shared/widgets/MdnDocsWidget"); * code by having a tag called "padding" and a property * value called "margin". */ -const TEST_DOC =` - - - - +const TEST_URI = ` + + + + - - MDN tooltip testing - -`; + + MDN tooltip testing + + +`; add_task(function* () { - - yield addTab("data:text/html;charset=utf8," + encodeURIComponent(TEST_DOC)); - + yield addTab("data:text/html;charset=utf8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("padding", inspector); - yield testMdnContextMenuItemVisibility(view); }); /** - * Test that the MDN context menu item is shown when it should be, + * Tests that the MDN context menu item is shown when it should be, * and hidden when it should be. * - iterate through every node in the rule view * - set that node as popupNode (the node that the context menu @@ -68,9 +66,10 @@ function* testMdnContextMenuItemVisibility(view) { view._contextmenu._updateMenuItems(); let isVisible = !view._contextmenu.menuitemShowMdnDocs.hidden; let shouldBeVisible = isPropertyNameNode(node); - let message = shouldBeVisible? "shown": "hidden"; + let message = shouldBeVisible ? "shown" : "hidden"; is(isVisible, shouldBeVisible, - "The MDN context menu item is " + message + " ; content : " + node.textContent + " ; type : " + node.nodeType); + "The MDN context menu item is " + message + " ; content : " + + node.textContent + " ; type : " + node.nodeType); } } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_context-menu-show-mdn-docs-02.js b/browser/devtools/styleinspector/test/browser_ruleview_context-menu-show-mdn-docs-02.js index f14966ed38bf..d594017eda2c 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_context-menu-show-mdn-docs-02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_context-menu-show-mdn-docs-02.js @@ -22,21 +22,19 @@ const {setBaseCssDocsUrl} = require("devtools/shared/widgets/MdnDocsWidget"); const PROPERTYNAME = "color"; const TEST_DOC = ` - - -
- Test "Show MDN Docs" context menu option -
- -`; + + +
+ Test "Show MDN Docs" context menu option +
+ + +`; add_task(function* () { - yield addTab("data:text/html;charset=utf8," + encodeURIComponent(TEST_DOC)); - let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); - yield testShowAndHideMdnTooltip(view); }); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_context-menu-show-mdn-docs-03.js b/browser/devtools/styleinspector/test/browser_ruleview_context-menu-show-mdn-docs-03.js index 7a066b8331f7..792e78524ea4 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_context-menu-show-mdn-docs-03.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_context-menu-show-mdn-docs-03.js @@ -15,17 +15,19 @@ "use strict"; const { PrefObserver } = require("devtools/styleeditor/utils"); -const PREF_ENABLE_MDN_DOCS_TOOLTIP = "devtools.inspector.mdnDocsTooltip.enabled"; +const PREF_ENABLE_MDN_DOCS_TOOLTIP = + "devtools.inspector.mdnDocsTooltip.enabled"; const PROPERTY_NAME_CLASS = "ruleview-propertyname"; const TEST_DOC = ` - - -
- Test the pref to enable/disable the "Show MDN Docs" context menu option -
- -`; + + +
+ Test the pref to enable/disable the "Show MDN Docs" context menu option +
+ + +`; add_task(function* () { info("Ensure the pref is true to begin with"); @@ -95,7 +97,7 @@ function* setBooleanPref(pref, state) { * menu item to be visible or not. */ function* testMdnContextMenuItemVisibility(view, shouldBeVisible) { - let message = shouldBeVisible? "shown": "hidden"; + let message = shouldBeVisible ? "shown" : "hidden"; info("Test that MDN context menu item is " + message); info("Set a CSS property name as popupNode"); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_copy_styles.js b/browser/devtools/styleinspector/test/browser_ruleview_copy_styles.js index 318302efbb9c..967d0e1fa098 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_copy_styles.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_copy_styles.js @@ -6,14 +6,14 @@ /** * Tests the behaviour of the copy styles context menu items in the rule - * view + * view. */ XPCOMUtils.defineLazyGetter(this, "osString", function() { return Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS; }); -let TEST_URI = TEST_URL_ROOT + "doc_copystyles.html"; +const TEST_URI = TEST_URL_ROOT + "doc_copystyles.html"; add_task(function*() { yield addTab(TEST_URI); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_cubicbezier-appears-on-swatch-click.js b/browser/devtools/styleinspector/test/browser_ruleview_cubicbezier-appears-on-swatch-click.js index 1e9132b4a48a..f9966dcf3900 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_cubicbezier-appears-on-swatch-click.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_cubicbezier-appears-on-swatch-click.js @@ -4,26 +4,26 @@ "use strict"; -// Test that cubic-bezier pickers appear when clicking on cubic-bezier swatches +// Tests that cubic-bezier pickers appear when clicking on cubic-bezier +// swatches. -const PAGE_CONTENT = [ - '', - '
Testing the cubic-bezier tooltip!
' -].join("\n"); +const TEST_URI = ` + +
Testing the cubic-bezier tooltip!
+`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,rule view cubic-bezier tooltip test"); - content.document.body.innerHTML = PAGE_CONTENT; - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); let swatches = []; diff --git a/browser/devtools/styleinspector/test/browser_ruleview_cubicbezier-commit-on-ENTER.js b/browser/devtools/styleinspector/test/browser_ruleview_cubicbezier-commit-on-ENTER.js index 3095cbfa210d..dea4acc7994d 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_cubicbezier-commit-on-ENTER.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_cubicbezier-commit-on-ENTER.js @@ -4,24 +4,23 @@ "use strict"; -// Test that a curve change in the cubic-bezier tooltip is committed when ENTER -// is pressed +// Tests that a curve change in the cubic-bezier tooltip is committed when ENTER +// is pressed. -const PAGE_CONTENT = [ - '' -].join("\n"); +const TEST_URI = ` + +`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,rule view cubic-bezier tooltip test"); - content.document.body.innerHTML = PAGE_CONTENT; - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {view} = yield openRuleView(); info("Getting the bezier swatch element"); - let swatch = getRuleViewProperty(view, "body" , "transition").valueSpan + let swatch = getRuleViewProperty(view, "body", "transition").valueSpan .querySelector(".ruleview-bezierswatch"); yield testPressingEnterCommitsChanges(swatch, view); @@ -41,7 +40,8 @@ function* testPressingEnterCommitsChanges(swatch, ruleView) { let expected = "cubic-bezier(0.1, 2, 0.9, -1)"; yield waitForSuccess(() => { - return content.getComputedStyle(content.document.body).transitionTimingFunction === expected; + return content.getComputedStyle(content.document.body) + .transitionTimingFunction === expected; }, "Waiting for the change to be previewed on the element"); ok(getRuleViewProperty(ruleView, "body", "transition").valueSpan.textContent diff --git a/browser/devtools/styleinspector/test/browser_ruleview_cubicbezier-revert-on-ESC.js b/browser/devtools/styleinspector/test/browser_ruleview_cubicbezier-revert-on-ESC.js index d0bbac9db514..6b703667bdf8 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_cubicbezier-revert-on-ESC.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_cubicbezier-revert-on-ESC.js @@ -4,16 +4,16 @@ "use strict"; -// Test that changes made to the cubic-bezier timing-function in the -// cubic-bezier tooltip are reverted when ESC is pressed +// Tests that changes made to the cubic-bezier timing-function in the +// cubic-bezier tooltip are reverted when ESC is pressed. -let TEST_URI = [ - "", -].join("\n"); +const TEST_URI = ` + +`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_custom.js b/browser/devtools/styleinspector/test/browser_ruleview_custom.js index 90d15103968f..84a310e12197 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_custom.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_custom.js @@ -6,7 +6,7 @@ const TEST_URI = TEST_URL_ROOT + "doc_custom.html"; -// Test the display of custom declarations in the rule-view +// Tests the display of custom declarations in the rule-view. add_task(function*() { yield addTab(TEST_URI); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_cycle-color.js b/browser/devtools/styleinspector/test/browser_ruleview_cycle-color.js index 1124cfe02b26..8c1eb8218f3e 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_cycle-color.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_cycle-color.js @@ -6,21 +6,18 @@ // Test cycling color types in the rule view. -const PAGE_CONTENT = [ - "", - "Test cycling color types in the rule view!" -].join("\n"); +const TEST_URI = ` + + Test cycling color types in the rule view! +`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,Test cycling color types in the " + - "rule view."); - content.document.body.innerHTML = PAGE_CONTENT; - let {toolbox, inspector, view} = yield openRuleView(); - + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); let container = getRuleViewProperty(view, "body", "color").valueSpan; checkColorCycling(container, inspector); }); @@ -34,27 +31,32 @@ function checkColorCycling(container, inspector) { is(valueNode.textContent, "#F00", "Color displayed as a hex value."); // HSL - EventUtils.synthesizeMouseAtCenter(swatch, {type: "mousedown", shiftKey: true}, win); + EventUtils.synthesizeMouseAtCenter(swatch, + {type: "mousedown", shiftKey: true}, win); is(valueNode.textContent, "hsl(0, 100%, 50%)", "Color displayed as an HSL value."); // RGB - EventUtils.synthesizeMouseAtCenter(swatch, {type: "mousedown", shiftKey: true}, win); + EventUtils.synthesizeMouseAtCenter(swatch, + {type: "mousedown", shiftKey: true}, win); is(valueNode.textContent, "rgb(255, 0, 0)", "Color displayed as an RGB value."); // Color name - EventUtils.synthesizeMouseAtCenter(swatch, {type: "mousedown", shiftKey: true}, win); + EventUtils.synthesizeMouseAtCenter(swatch, + {type: "mousedown", shiftKey: true}, win); is(valueNode.textContent, "red", "Color displayed as a color name."); // "Authored" (currently the computed value) - EventUtils.synthesizeMouseAtCenter(swatch, {type: "mousedown", shiftKey: true}, win); + EventUtils.synthesizeMouseAtCenter(swatch, + {type: "mousedown", shiftKey: true}, win); is(valueNode.textContent, "rgb(255, 0, 0)", "Color displayed as an RGB value."); // Back to hex - EventUtils.synthesizeMouseAtCenter(swatch, {type: "mousedown", shiftKey: true}, win); + EventUtils.synthesizeMouseAtCenter(swatch, + {type: "mousedown", shiftKey: true}, win); is(valueNode.textContent, "#F00", "Color displayed as hex again."); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-property-cancel.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-property-cancel.js index 299660374657..91fa3885ef56 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-property-cancel.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-property-cancel.js @@ -7,14 +7,14 @@ // Tests editing a property name or value and escaping will revert the // changes and restore the original value. -let TEST_URI = [ - "", - "
Styled Node
", -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-property-commit.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-property-commit.js index 3124d1bb4e64..2940b29dd365 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-property-commit.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-property-commit.js @@ -7,7 +7,14 @@ // Test original value is correctly displayed when ESCaping out of the // inplace editor in the style inspector. -const originalValue = "#00F"; +const TEST_URI = ` + +
Styled Node
+`; // Test data format // { @@ -17,44 +24,41 @@ const originalValue = "#00F"; // expected: what value is expected as a result // } const testData = [ - {value: "red", commitKey: "VK_ESCAPE", modifiers: {}, expected: originalValue}, - {value: "red", commitKey: "VK_RETURN", modifiers: {}, expected: "red"}, - {value: "invalid", commitKey: "VK_RETURN", modifiers: {}, expected: "invalid"}, - {value: "blue", commitKey: "VK_TAB", modifiers: {shiftKey: true}, expected: "blue"} + { + value: "red", + commitKey: "VK_ESCAPE", + modifiers: {}, + expected: "#00F" + }, + { + value: "red", + commitKey: "VK_RETURN", + modifiers: {}, + expected: "red" + }, + { + value: "invalid", + commitKey: "VK_RETURN", + modifiers: {}, + expected: "invalid" + }, + { + value: "blue", + commitKey: "VK_TAB", modifiers: {shiftKey: true}, + expected: "blue" + } ]; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,test escaping property change reverts back to original value"); - - info("Creating the test document"); - createDocument(); - - info("Opening the rule view"); - let {toolbox, inspector, view} = yield openRuleView(); - - info("Selecting the test node"); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); - info("Iterating over the test data"); for (let data of testData) { yield runTestData(view, data); } }); -function createDocument() { - let style = '' + - '#testid {' + - ' color: ' + originalValue + ';' + - '}'; - - let node = content.document.createElement('style'); - node.setAttribute("type", "text/css"); - node.textContent = style; - content.document.getElementsByTagName("head")[0].appendChild(node); - - content.document.body.innerHTML = '
Styled Node
'; -} - function* runTestData(view, {value, commitKey, modifiers, expected}) { let idRuleEditor = getRuleViewRuleEditor(view, 1); let propEditor = idRuleEditor.rule.textProps[0].editor; @@ -62,7 +66,8 @@ function* runTestData(view, {value, commitKey, modifiers, expected}) { info("Focusing the inplace editor field"); let editor = yield focusEditableField(view, propEditor.valueSpan); - is(inplaceEditor(propEditor.valueSpan), editor, "Focused editor should be the value span."); + is(inplaceEditor(propEditor.valueSpan), editor, + "Focused editor should be the value span."); info("Entering test data " + value); let onRuleViewChanged = view.once("ruleview-changed"); @@ -79,8 +84,10 @@ function* runTestData(view, {value, commitKey, modifiers, expected}) { yield onRuleViewChanged; if (commitKey === "VK_ESCAPE") { - is(propEditor.valueSpan.textContent, expected, "Value is as expected: " + expected); + is(propEditor.valueSpan.textContent, expected, + "Value is as expected: " + expected); } else { - is(propEditor.valueSpan.textContent, expected, "Value is as expected: " + expected); + is(propEditor.valueSpan.textContent, expected, + "Value is as expected: " + expected); } } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-property-computed.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-property-computed.js index f2221f196d07..f37d1f46ff41 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-property-computed.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-property-computed.js @@ -6,16 +6,17 @@ // Test that the computed values of a style (the shorthand expansion) are // properly updated after the style is changed. -add_task(function*() { - let TEST_URI = [ - '', - '
Styled Node
' - ].join('\n'); +const TEST_URI = ` + +
Styled Node
+`; + +add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); @@ -30,14 +31,17 @@ function* editAndCheck(view) { info("Focusing the inplace editor field"); let editor = yield focusEditableField(view, propEditor.valueSpan); - is(inplaceEditor(propEditor.valueSpan), editor, "Focused editor should be the value span."); + is(inplaceEditor(propEditor.valueSpan), editor, + "Focused editor should be the value span."); - let onPropertyChange = waitForComputedStyleProperty("#testid", null, "padding-top", newPaddingValue); + let onPropertyChange = waitForComputedStyleProperty("#testid", null, + "padding-top", newPaddingValue); info("Entering a new value"); EventUtils.sendString(newPaddingValue, view.styleWindow); - info("Waiting for the throttled previewValue to apply the changes to document"); + info("Waiting for the throttled previewValue to apply the " + + "changes to document"); yield onPropertyChange; let onBlur = once(editor.input, "blur"); @@ -61,15 +65,19 @@ function* editAndCheck(view) { is(computed.length, propNames.length, "There should be 4 computed values"); propNames.forEach((propName, i) => { - is(computed[i].name, propName, "Computed property #" + i + " has name " + propName); - is(computed[i].value, newPaddingValue, "Computed value of " + propName + " is as expected"); + is(computed[i].name, propName, + "Computed property #" + i + " has name " + propName); + is(computed[i].value, newPaddingValue, + "Computed value of " + propName + " is as expected"); }); propEditor.expander.click(); let computedDom = propEditor.computed; - is(computedDom.children.length, propNames.length, "There should be 4 nodes in the DOM"); + is(computedDom.children.length, propNames.length, + "There should be 4 nodes in the DOM"); propNames.forEach((propName, i) => { - is(computedDom.getElementsByClassName("ruleview-propertyvalue")[i].textContent, - newPaddingValue, "Computed value of " + propName + " in DOM is as expected"); + is(computedDom.getElementsByClassName("ruleview-propertyvalue")[i] + .textContent, newPaddingValue, + "Computed value of " + propName + " in DOM is as expected"); }); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-property-order.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-property-order.js index 7cfd6bcd7753..0c088c9d2135 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-property-order.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-property-order.js @@ -4,18 +4,16 @@ "use strict"; -// Checking properties orders and overrides in the rule-view +// Checking properties orders and overrides in the rule-view. + +const TEST_URI = "
Styled Node
"; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,browser_ruleview_manipulation.js"); - let {toolbox, inspector, view} = yield openRuleView(); - - info("Creating the test document and getting the test node"); - content.document.body.innerHTML = '
Styled Node
'; - let element = getNode("#testid"); - + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); + let element = getNode("#testid"); let elementStyle = view._elementStyle; let elementRule = elementStyle.rules[0]; @@ -23,46 +21,62 @@ add_task(function*() { let firstProp = elementRule.createProperty("background-color", "green", ""); let secondProp = elementRule.createProperty("background-color", "blue", ""); is(elementRule.textProps[0], firstProp, "Rules should be in addition order."); - is(elementRule.textProps[1], secondProp, "Rules should be in addition order."); + is(elementRule.textProps[1], secondProp, + "Rules should be in addition order."); yield elementRule._applyingModifications; - is(element.style.getPropertyValue("background-color"), "blue", "Second property should have been used."); + is(element.style.getPropertyValue("background-color"), "blue", + "Second property should have been used."); info("Removing the second property and checking the applied style again"); secondProp.remove(); yield elementRule._applyingModifications; - is(element.style.getPropertyValue("background-color"), "green", "After deleting second property, first should be used."); + is(element.style.getPropertyValue("background-color"), "green", + "After deleting second property, first should be used."); - info("Creating a new second property and checking that the insertion order is still the same"); + info("Creating a new second property and checking that the insertion order " + + "is still the same"); secondProp = elementRule.createProperty("background-color", "blue", ""); yield elementRule._applyingModifications; - is(element.style.getPropertyValue("background-color"), "blue", "New property should be used."); - is(elementRule.textProps[0], firstProp, "Rules shouldn't have switched places."); - is(elementRule.textProps[1], secondProp, "Rules shouldn't have switched places."); + is(element.style.getPropertyValue("background-color"), "blue", + "New property should be used."); + is(elementRule.textProps[0], firstProp, + "Rules shouldn't have switched places."); + is(elementRule.textProps[1], secondProp, + "Rules shouldn't have switched places."); info("Disabling the second property and checking the applied style"); secondProp.setEnabled(false); yield elementRule._applyingModifications; - is(element.style.getPropertyValue("background-color"), "green", "After disabling second property, first value should be used"); + is(element.style.getPropertyValue("background-color"), "green", + "After disabling second property, first value should be used"); info("Disabling the first property too and checking the applied style"); firstProp.setEnabled(false); yield elementRule._applyingModifications; - is(element.style.getPropertyValue("background-color"), "", "After disabling both properties, value should be empty."); + is(element.style.getPropertyValue("background-color"), "", + "After disabling both properties, value should be empty."); info("Re-enabling the second propertyt and checking the applied style"); secondProp.setEnabled(true); yield elementRule._applyingModifications; - is(element.style.getPropertyValue("background-color"), "blue", "Value should be set correctly after re-enabling"); + is(element.style.getPropertyValue("background-color"), "blue", + "Value should be set correctly after re-enabling"); - info("Re-enabling the first property and checking the insertion order is still respected"); + info("Re-enabling the first property and checking the insertion order " + + "is still respected"); firstProp.setEnabled(true); yield elementRule._applyingModifications; - is(element.style.getPropertyValue("background-color"), "blue", "Re-enabling an earlier property shouldn't make it override a later property."); - is(elementRule.textProps[0], firstProp, "Rules shouldn't have switched places."); - is(elementRule.textProps[1], secondProp, "Rules shouldn't have switched places."); + is(element.style.getPropertyValue("background-color"), "blue", + "Re-enabling an earlier property shouldn't make it override " + + "a later property."); + is(elementRule.textProps[0], firstProp, + "Rules shouldn't have switched places."); + is(elementRule.textProps[1], secondProp, + "Rules shouldn't have switched places."); info("Modifying the first property and checking the applied style"); firstProp.setValue("purple", ""); yield elementRule._applyingModifications; - is(element.style.getPropertyValue("background-color"), "blue", "Modifying an earlier property shouldn't override a later property."); + is(element.style.getPropertyValue("background-color"), "blue", + "Modifying an earlier property shouldn't override a later property."); }); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-property-remove_01.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-property-remove_01.js index 96562556906e..2fdf8031312f 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-property-remove_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-property-remove_01.js @@ -8,15 +8,15 @@ // return key, and checks if the focus is moved to the appropriate editable // field. -let TEST_URI = [ - "", - "
Styled Node
", -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-property-remove_02.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-property-remove_02.js index 524cd908760c..e9a9d2bf7bbb 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-property-remove_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-property-remove_02.js @@ -8,15 +8,15 @@ // return key, and checks if the focus is moved to the appropriate editable // field. -let TEST_URI = [ - "", - "
Styled Node
", -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-property-remove_03.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-property-remove_03.js index 92d8faa626a8..53ad3c4ec405 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-property-remove_03.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-property-remove_03.js @@ -7,15 +7,16 @@ // Tests removing a property by clearing the property name and pressing shift // and tab keys, and checks if the focus is moved to the appropriate editable // field. -let TEST_URI = [ - "", - "
Styled Node
", -].join("\n"); + +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-property_01.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-property_01.js index 5517e212d4f7..b2d774c570b4 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-property_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-property_01.js @@ -9,20 +9,21 @@ // FIXME: some of the inplace-editor focus/blur/commit/revert stuff // should be factored out in head.js +const TEST_URI = ` + +
Styled Node
+
Styled Node
+`; + let BACKGROUND_IMAGE_URL = 'url("' + TEST_URL_ROOT + 'doc_test_image.png")'; -let TEST_URI = [ - '', - '
Styled Node
', - '
Styled Node
' -].join("\n"); let TEST_DATA = [ { name: "border-color", value: "red", isValid: true }, @@ -31,12 +32,8 @@ let TEST_DATA = [ ]; add_task(function*() { - let tab = yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - - info("Opening the rule-view"); - let {toolbox, inspector, view} = yield openRuleView(); - - info("Selecting the test element"); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); let ruleEditor = getRuleViewRuleEditor(view, 1); @@ -52,12 +49,15 @@ function* testEditProperty(ruleEditor, name, value, isValid) { let propEditor = ruleEditor.rule.textProps[0].editor; info("Focusing an existing property name in the rule-view"); - let editor = yield focusEditableField(ruleEditor.ruleView, propEditor.nameSpan, 32, 1); + let editor = yield focusEditableField(ruleEditor.ruleView, + propEditor.nameSpan, 32, 1); - is(inplaceEditor(propEditor.nameSpan), editor, "The property name editor got focused"); + is(inplaceEditor(propEditor.nameSpan), editor, + "The property name editor got focused"); let input = editor.input; - info("Entering a new property name, including : to commit and focus the value"); + info("Entering a new property name, including : to commit and " + + "focus the value"); let onValueFocus = once(ruleEditor.element, "focus", true); let onModifications = ruleEditor.rule._applyingModifications; EventUtils.sendString(name + ":", doc.defaultView); @@ -76,7 +76,8 @@ function* testEditProperty(ruleEditor, name, value, isValid) { yield onBlur; yield onModifications; - is(propEditor.isValid(), isValid, value + " is " + isValid ? "valid" : "invalid"); + is(propEditor.isValid(), isValid, + value + " is " + isValid ? "valid" : "invalid"); info("Checking that the style property was changed on the content page"); let propValue = yield executeInContent("Test:GetRulePropertyValue", { diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-property_02.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-property_02.js index 5a33ab3ce7ec..6e7f1361ac07 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-property_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-property_02.js @@ -6,25 +6,24 @@ // Test several types of rule-view property edition -let TEST_URI = [ - '', - '
Styled Node
', - '
Styled Node
' -].join("\n"); +const TEST_URI = ` + +
Styled Node
+
Styled Node
+`; add_task(function*() { - let tab = yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - - let {toolbox, inspector, view} = yield openRuleView(); - + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); + yield testEditProperty(inspector, view); yield testDisableProperty(inspector, view); yield testPropertyStillMarkedDirty(inspector, view); @@ -36,15 +35,19 @@ function* testEditProperty(inspector, ruleView) { let editor = yield focusEditableField(ruleView, propEditor.nameSpan); let input = editor.input; - is(inplaceEditor(propEditor.nameSpan), editor, "Next focused editor should be the name editor."); + is(inplaceEditor(propEditor.nameSpan), editor, + "Next focused editor should be the name editor."); - ok(input.selectionStart === 0 && input.selectionEnd === input.value.length, "Editor contents are selected."); + ok(input.selectionStart === 0 && input.selectionEnd === input.value.length, + "Editor contents are selected."); - // Try clicking on the editor's input again, shouldn't cause trouble (see bug 761665). + // Try clicking on the editor's input again, shouldn't cause trouble + // (see bug 761665). EventUtils.synthesizeMouse(input, 1, 1, {}, ruleView.styleWindow); input.select(); - info("Entering property name \"border-color\" followed by a colon to focus the value"); + info("Entering property name \"border-color\" followed by a colon to " + + "focus the value"); let onFocus = once(idRuleEditor.element, "focus", true); EventUtils.sendString("border-color:", ruleView.styleWindow); yield onFocus; @@ -53,12 +56,15 @@ function* testEditProperty(inspector, ruleView) { info("Verifying that the focused field is the valueSpan"); editor = inplaceEditor(ruleView.styleDocument.activeElement); input = editor.input; - is(inplaceEditor(propEditor.valueSpan), editor, "Focus should have moved to the value."); - ok(input.selectionStart === 0 && input.selectionEnd === input.value.length, "Editor contents are selected."); + is(inplaceEditor(propEditor.valueSpan), editor, + "Focus should have moved to the value."); + ok(input.selectionStart === 0 && input.selectionEnd === input.value.length, + "Editor contents are selected."); info("Entering a value following by a semi-colon to commit it"); let onBlur = once(editor.input, "blur"); - // Use sendChar() to pass each character as a string so that we can test propEditor.warning.hidden after each character. + // Use sendChar() to pass each character as a string so that we can test + // propEditor.warning.hidden after each character. for (let ch of "red;") { EventUtils.sendChar(ch, ruleView.styleWindow); is(propEditor.warning.hidden, true, @@ -74,7 +80,8 @@ function* testEditProperty(inspector, ruleView) { }); is(newValue, "red", "border-color should have been set."); - info("Entering property name \"color\" followed by a colon to focus the value"); + info("Entering property name \"color\" followed by a colon to " + + "focus the value"); onFocus = once(idRuleEditor.element, "focus", true); EventUtils.sendString("color:", ruleView.styleWindow); yield onFocus; diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-property_03.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-property_03.js index 7b2e568b34e2..05fae84ad8e6 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-property_03.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-property_03.js @@ -7,45 +7,42 @@ // Tests that emptying out an existing value removes the property and // doesn't cause any other issues. See also Bug 1150780. -let TEST_URI = [ - '', - '
Styled Node
', - '
Styled Node
' -].join("\n"); +const TEST_URI = ` + +
Styled Node
+
Styled Node
+`; add_task(function*() { - let tab = yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - - info("Opening the rule-view"); - let {toolbox, inspector, view} = yield openRuleView(); - - info("Selecting the test element"); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); let ruleEditor = getRuleViewRuleEditor(view, 1); - let doc = ruleEditor.doc; - let propEditor = ruleEditor.rule.textProps[1].editor; - let editor = yield focusEditableField(view, propEditor.valueSpan); + + yield focusEditableField(view, propEditor.valueSpan); info("Deleting all the text out of a value field"); - yield sendCharsAndWaitForFocus(view, ruleEditor.element, ["VK_DELETE", "VK_RETURN"]); + yield sendCharsAndWaitForFocus(view, ruleEditor.element, + ["VK_DELETE", "VK_RETURN"]); info("Pressing enter a couple times to cycle through editors"); yield sendCharsAndWaitForFocus(view, ruleEditor.element, ["VK_RETURN"]); yield sendCharsAndWaitForFocus(view, ruleEditor.element, ["VK_RETURN"]); - isnot (ruleEditor.rule.textProps[1].editor.nameSpan.style.display, "none", "The name span is visible"); - is (ruleEditor.rule.textProps.length, 2, "Correct number of props"); + isnot(ruleEditor.rule.textProps[1].editor.nameSpan.style.display, "none", + "The name span is visible"); + is(ruleEditor.rule.textProps.length, 2, "Correct number of props"); }); function* sendCharsAndWaitForFocus(view, element, chars) { diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-property_04.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-property_04.js index 24eccbff8260..880a1c70d165 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-property_04.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-property_04.js @@ -7,14 +7,14 @@ // Tests that a disabled property remains disabled when the escaping out of // the property editor. -let TEST_URI = [ - "", - "
Styled Node
", -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-property_05.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-property_05.js index 583704906f40..a346b275593b 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-property_05.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-property_05.js @@ -7,14 +7,14 @@ // Tests that a disabled property is re-enabled if the property name or value is // modified -let TEST_URI = [ - "", - "
Styled Node
", -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-property_06.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-property_06.js index f15cf518ff0f..1025292d2a4c 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-property_06.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-property_06.js @@ -7,16 +7,16 @@ // Tests that editing a property's priority is behaving correctly, and disabling // and editing the property will re-enable the property. -let TEST_URI = [ - "", -].join("\n"); +const TEST_URI = ` + +`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-property_07.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-property_07.js index 72364c5d4557..25591ce16548 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-property_07.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-property_07.js @@ -7,14 +7,14 @@ // Tests that adding multiple values will enable the property even if the // property does not change, and that the extra values are added correctly. -let TEST_URI = [ - "", - "
Styled Node
", -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-selector-commit.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-selector-commit.js index 0665c6fba38f..7055d7f2999e 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-selector-commit.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-selector-commit.js @@ -7,21 +7,21 @@ // Test selector value is correctly displayed when committing the inplace editor // with ENTER, ESC, SHIFT+TAB and TAB -let TEST_URI = [ - "", - "
Styled Node
", - "
Styled Node
", - "
Styled Node
", -].join("\n"); +const TEST_URI = ` + +
Styled Node
+
Styled Node
+
Styled Node
+`; const TEST_DATA = [ { @@ -59,7 +59,6 @@ add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let { inspector, view } = yield openRuleView(); - info("Iterating over the test data"); for (let data of TEST_DATA) { yield runTestData(inspector, view, data); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_01.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_01.js index 89e49b5ffd73..d1aef87dc3bd 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_01.js @@ -6,18 +6,18 @@ // Testing selector inplace-editor behaviors in the rule-view -let PAGE_CONTENT = [ - '', - '
Styled Node
', - 'This is a span', -].join("\n"); +const TEST_URI = ` + +
Styled Node
+ This is a span +`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(PAGE_CONTENT)); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); info("Selecting the test element"); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_02.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_02.js index ba9e1e3ff11d..600d475b5f10 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_02.js @@ -7,20 +7,20 @@ // Testing selector inplace-editor behaviors in the rule-view with pseudo // classes. -let PAGE_CONTENT = [ - '', - '
Styled Node
', - 'This is a span', - '
A
', - '
B
' -].join("\n"); +const TEST_URI = ` + +
Styled Node
+ This is a span +
A
+
B
+`; const PSEUDO_PREF = "devtools.inspector.show_pseudo_elements"; @@ -28,7 +28,7 @@ add_task(function*() { // Expand the pseudo-elements section by default. Services.prefs.setBoolPref(PSEUDO_PREF, true); - yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(PAGE_CONTENT)); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); info("Selecting the test element"); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_03.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_03.js index 03d047e41c89..57f85c30b7e2 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_03.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_03.js @@ -7,14 +7,14 @@ // Testing selector inplace-editor behaviors in the rule-view with invalid // selectors -let TEST_URI = [ - '', - '
Styled Node
', -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_04.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_04.js index f3248b3da6c1..01f2933c03cf 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_04.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_04.js @@ -7,22 +7,23 @@ // Tests that the selector highlighter is removed when modifying a selector and // the selector highlighter works for the newly added unmatched rule. -const TEST_URI = [ - '', - '

Test the selector highlighter

' -].join("\n"); +const TEST_URI = ` + +

Test the selector highlighter

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); - - ok(!view.selectorHighlighter, "No selectorhighlighter exist in the rule-view"); - yield selectNode("p", inspector); + + ok(!view.selectorHighlighter, + "No selectorhighlighter exist in the rule-view"); + yield testSelectorHighlight(view, "p"); yield testEditSelector(view, "body"); yield testSelectorHighlight(view, "body"); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_05.js b/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_05.js index 424ec44831f9..216fc19aae4d 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_05.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_edit-selector_05.js @@ -6,17 +6,17 @@ // Tests that adding a new property of an unmatched rule works properly. -let TEST_URI = [ - '', - '
Styled Node
', - 'This is a span' -].join("\n"); +const TEST_URI = ` + +
Styled Node
+ This is a span +`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); @@ -90,7 +90,7 @@ function* testAddProperty(view) { editor = inplaceEditor(view.styleDocument.activeElement); let textProp = ruleEditor.rule.textProps[0]; - is(ruleEditor.rule.textProps.length, 1, "Created a new text property."); + is(ruleEditor.rule.textProps.length, 1, "Created a new text property."); is(ruleEditor.propertyList.children.length, 1, "Created a property editor."); is(editor, inplaceEditor(textProp.editor.valueSpan), "Editing the value span now."); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_editable-field-focus_01.js b/browser/devtools/styleinspector/test/browser_ruleview_editable-field-focus_01.js index a8534f121e92..9981b1233e3b 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_editable-field-focus_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_editable-field-focus_01.js @@ -7,20 +7,20 @@ // Tests that the correct editable fields are focused when tabbing and entering // through the rule view. -let TEST_URI = [ - "", - "
Styled Node
", -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_editable-field-focus_02.js b/browser/devtools/styleinspector/test/browser_ruleview_editable-field-focus_02.js index dc08386799a5..af5e2b9bc630 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_editable-field-focus_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_editable-field-focus_02.js @@ -7,20 +7,20 @@ // Tests that the correct editable fields are focused when shift tabbing // through the rule view. -let TEST_URI = [ - "", - "
Styled Node
", -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_eyedropper.js b/browser/devtools/styleinspector/test/browser_ruleview_eyedropper.js index 495c75d0de7a..9180514bd5ea 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_eyedropper.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_eyedropper.js @@ -7,7 +7,7 @@ // So we can test collecting telemetry on the eyedropper let oldCanRecord = Services.telemetry.canRecordExtended; Services.telemetry.canRecordExtended = true; -registerCleanupFunction(function () { +registerCleanupFunction(function() { Services.telemetry.canRecordExtended = oldCanRecord; }); const HISTOGRAM_ID = "DEVTOOLS_PICKER_EYEDROPPER_OPENED_BOOLEAN"; @@ -15,30 +15,30 @@ const FLAG_HISTOGRAM_ID = "DEVTOOLS_PICKER_EYEDROPPER_OPENED_PER_USER_FLAG"; const EXPECTED_TELEMETRY = { "DEVTOOLS_PICKER_EYEDROPPER_OPENED_BOOLEAN": 2, "DEVTOOLS_PICKER_EYEDROPPER_OPENED_PER_USER_FLAG": 1 -} +}; -const PAGE_CONTENT = [ - '', - '
' -].join("\n"); +const TEST_URI = ` + +
+`; const ORIGINAL_COLOR = "rgb(255, 0, 153)"; // #f09 const EXPECTED_COLOR = "rgb(255, 255, 85)"; // #ff5 @@ -50,10 +50,8 @@ add_task(function*() { // clear telemetry so we can get accurate counts clearTelemetry(); - yield addTab("data:text/html;charset=utf-8,rule view eyedropper test"); - content.document.body.innerHTML = PAGE_CONTENT; - - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("#div2", inspector); let property = getRuleViewProperty(view, "#div2", "background-color"); @@ -124,8 +122,8 @@ function checkTelemetry() { let histogram = Services.telemetry.getHistogramById(histogramId); let snapshot = histogram.snapshot(); - is (snapshot.counts[1], expected, - "eyedropper telemetry value correct for " + histogramId); + is(snapshot.counts[1], expected, + "eyedropper telemetry value correct for " + histogramId); } } @@ -141,7 +139,7 @@ function openEyedropper(view, swatch) { let dropperButton = tooltipDoc.querySelector("#eyedropper-button"); tooltip.once("eyedropper-opened", (event, dropper) => { - deferred.resolve(dropper) + deferred.resolve(dropper); }); dropperButton.click(); }); @@ -163,7 +161,8 @@ function inspectPage(dropper, click=true) { EventUtils.synthesizeMouse(target, x, y, { type: "mousemove" }, win); return dropperLoaded(dropper).then(() => { - EventUtils.synthesizeMouse(target, x + 10, y + 10, { type: "mousemove" }, win); + EventUtils.synthesizeMouse(target, x + 10, y + 10, + { type: "mousemove" }, win); if (click) { EventUtils.synthesizeMouse(target, x + 10, y + 10, {}, win); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_filtereditor-appears-on-swatch-click.js b/browser/devtools/styleinspector/test/browser_ruleview_filtereditor-appears-on-swatch-click.js index 140848ffa7e0..e58065426829 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_filtereditor-appears-on-swatch-click.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_filtereditor-appears-on-swatch-click.js @@ -10,7 +10,7 @@ const TEST_URL = TEST_URL_ROOT + "doc_filter.html"; add_task(function*() { yield addTab(TEST_URL); - let {toolbox, inspector, view} = yield openRuleView(); + let {view} = yield openRuleView(); info("Getting the filter swatch element"); let swatch = getRuleViewProperty(view, "body", "filter").valueSpan diff --git a/browser/devtools/styleinspector/test/browser_ruleview_filtereditor-commit-on-ENTER.js b/browser/devtools/styleinspector/test/browser_ruleview_filtereditor-commit-on-ENTER.js index ff164ef3cd7f..e572c9b149ec 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_filtereditor-commit-on-ENTER.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_filtereditor-commit-on-ENTER.js @@ -9,8 +9,7 @@ const TEST_URL = TEST_URL_ROOT + "doc_filter.html"; add_task(function*() { yield addTab(TEST_URL); - - let {toolbox, inspector, view} = yield openRuleView(); + let {view} = yield openRuleView(); info("Getting the filter swatch element"); let swatch = getRuleViewProperty(view, "body", "filter").valueSpan diff --git a/browser/devtools/styleinspector/test/browser_ruleview_inherit.js b/browser/devtools/styleinspector/test/browser_ruleview_inherit.js deleted file mode 100644 index 50dd49f20160..000000000000 --- a/browser/devtools/styleinspector/test/browser_ruleview_inherit.js +++ /dev/null @@ -1,86 +0,0 @@ -/* 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"; - -// Check that inherited properties appear as such in the rule-view - -let {ELEMENT_STYLE} = require("devtools/server/actors/styles"); - -add_task(function*() { - yield addTab("data:text/html;charset=utf-8,browser_inspector_changes.js"); - let {toolbox, inspector, view} = yield openRuleView(); - - yield simpleInherit(inspector, view); - yield emptyInherit(inspector, view); - yield elementStyleInherit(inspector, view); -}); - -function* simpleInherit(inspector, view) { - let style = '' + - '#test2 {' + - ' background-color: green;' + - ' color: purple;' + - '}'; - - let styleNode = addStyle(content.document, style); - content.document.body.innerHTML = '
Styled Node
'; - - yield selectNode("#test1", inspector); - - let elementStyle = view._elementStyle; - is(elementStyle.rules.length, 2, "Should have 2 rules."); - - let elementRule = elementStyle.rules[0]; - ok(!elementRule.inherited, "Element style attribute should not consider itself inherited."); - - let inheritRule = elementStyle.rules[1]; - is(inheritRule.selectorText, "#test2", "Inherited rule should be the one that includes inheritable properties."); - ok(!!inheritRule.inherited, "Rule should consider itself inherited."); - is(inheritRule.textProps.length, 1, "Should only display one inherited style"); - let inheritProp = inheritRule.textProps[0]; - is(inheritProp.name, "color", "color should have been inherited."); - - styleNode.remove(); -} - -function* emptyInherit(inspector, view) { - // No inheritable styles, this rule shouldn't show up. - let style = '' + - '#test2 {' + - ' background-color: green;' + - '}'; - - let styleNode = addStyle(content.document, style); - content.document.body.innerHTML = '
Styled Node
'; - - yield selectNode("#test1", inspector); - - let elementStyle = view._elementStyle; - is(elementStyle.rules.length, 1, "Should have 1 rule."); - - let elementRule = elementStyle.rules[0]; - ok(!elementRule.inherited, "Element style attribute should not consider itself inherited."); - - styleNode.parentNode.removeChild(styleNode); -} - -function* elementStyleInherit(inspector, view) { - content.document.body.innerHTML = '
Styled Node
'; - - yield selectNode("#test1", inspector); - - let elementStyle = view._elementStyle; - is(elementStyle.rules.length, 2, "Should have 2 rules."); - - let elementRule = elementStyle.rules[0]; - ok(!elementRule.inherited, "Element style attribute should not consider itself inherited."); - - let inheritRule = elementStyle.rules[1]; - is(inheritRule.domRule.type, ELEMENT_STYLE, "Inherited rule should be an element style, not a rule."); - ok(!!inheritRule.inherited, "Rule should consider itself inherited."); - is(inheritRule.textProps.length, 1, "Should only display one inherited style"); - let inheritProp = inheritRule.textProps[0]; - is(inheritProp.name, "color", "color should have been inherited."); -} diff --git a/browser/devtools/styleinspector/test/browser_ruleview_inherited-properties_01.js b/browser/devtools/styleinspector/test/browser_ruleview_inherited-properties_01.js new file mode 100644 index 000000000000..9d49ac034922 --- /dev/null +++ b/browser/devtools/styleinspector/test/browser_ruleview_inherited-properties_01.js @@ -0,0 +1,45 @@ +/* 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"; + +// Check that inherited properties appear for a nested element in the +// rule view. + +let {ELEMENT_STYLE} = require("devtools/server/actors/styles"); + +const TEST_URI = ` + +
Styled Node
+`; + +add_task(function*() { + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); + yield selectNode("#test1", inspector); + yield simpleInherit(inspector, view); +}); + +function* simpleInherit(inspector, view) { + let elementStyle = view._elementStyle; + is(elementStyle.rules.length, 2, "Should have 2 rules."); + + let elementRule = elementStyle.rules[0]; + ok(!elementRule.inherited, + "Element style attribute should not consider itself inherited."); + + let inheritRule = elementStyle.rules[1]; + is(inheritRule.selectorText, "#test2", + "Inherited rule should be the one that includes inheritable properties."); + ok(!!inheritRule.inherited, "Rule should consider itself inherited."); + is(inheritRule.textProps.length, 1, + "Should only display one inherited style"); + let inheritProp = inheritRule.textProps[0]; + is(inheritProp.name, "color", "color should have been inherited."); +} diff --git a/browser/devtools/styleinspector/test/browser_ruleview_inherited-properties_02.js b/browser/devtools/styleinspector/test/browser_ruleview_inherited-properties_02.js new file mode 100644 index 000000000000..15b910c8664d --- /dev/null +++ b/browser/devtools/styleinspector/test/browser_ruleview_inherited-properties_02.js @@ -0,0 +1,36 @@ +/* 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"; + +// Check that no inherited properties appear when the property does not apply +// to the nested element. + +let {ELEMENT_STYLE} = require("devtools/server/actors/styles"); + +const TEST_URI = ` + +
Styled Node
+`; + +add_task(function*() { + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); + yield selectNode("#test1", inspector); + yield emptyInherit(inspector, view); +}); + +function* emptyInherit(inspector, view) { + // No inheritable styles, this rule shouldn't show up. + let elementStyle = view._elementStyle; + is(elementStyle.rules.length, 1, "Should have 1 rule."); + + let elementRule = elementStyle.rules[0]; + ok(!elementRule.inherited, + "Element style attribute should not consider itself inherited."); +} diff --git a/browser/devtools/styleinspector/test/browser_ruleview_inherited-properties_03.js b/browser/devtools/styleinspector/test/browser_ruleview_inherited-properties_03.js new file mode 100644 index 000000000000..bb7af19be3f0 --- /dev/null +++ b/browser/devtools/styleinspector/test/browser_ruleview_inherited-properties_03.js @@ -0,0 +1,40 @@ +/* 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"; + +// Check that inline inherited properties appear in the nested element. + +let {ELEMENT_STYLE} = require("devtools/server/actors/styles"); + +const TEST_URI = ` +
+
Styled Node
+
+`; + +add_task(function*() { + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); + yield selectNode("#test1", inspector); + yield elementStyleInherit(inspector, view); +}); + +function* elementStyleInherit(inspector, view) { + let elementStyle = view._elementStyle; + is(elementStyle.rules.length, 2, "Should have 2 rules."); + + let elementRule = elementStyle.rules[0]; + ok(!elementRule.inherited, + "Element style attribute should not consider itself inherited."); + + let inheritRule = elementStyle.rules[1]; + is(inheritRule.domRule.type, ELEMENT_STYLE, + "Inherited rule should be an element style, not a rule."); + ok(!!inheritRule.inherited, "Rule should consider itself inherited."); + is(inheritRule.textProps.length, 1, + "Should only display one inherited style"); + let inheritProp = inheritRule.textProps[0]; + is(inheritProp.name, "color", "color should have been inherited."); +} diff --git a/browser/devtools/styleinspector/test/browser_ruleview_keybindings.js b/browser/devtools/styleinspector/test/browser_ruleview_keybindings.js index d832a95cdad0..2cda1bea73c6 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_keybindings.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_keybindings.js @@ -9,9 +9,7 @@ add_task(function*() { yield addTab("data:text/html;charset=utf-8,

Some header text

"); - let {toolbox, inspector, view} = yield openRuleView(); - - info("Selecting the test node"); + let {inspector, view} = yield openRuleView(); yield selectNode("h1", inspector); info("Getting the ruleclose brace element"); @@ -30,7 +28,8 @@ add_task(function*() { onFocus = once(brace.parentNode, "focus", true); // The rule view changes twice, once for the first field to loose focus // and a second time for the second field to gain focus - let onRuleViewChanged = view.once("ruleview-changed").then(() => view.once("ruleview-changed")); + let onRuleViewChanged = view.once("ruleview-changed").then( + () => view.once("ruleview-changed")); EventUtils.sendKey("return"); yield onFocus; yield onRuleViewChanged; diff --git a/browser/devtools/styleinspector/test/browser_ruleview_keyframes-rule_01.js b/browser/devtools/styleinspector/test/browser_ruleview_keyframes-rule_01.js index 001897f23e68..63533b9be0c4 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_keyframes-rule_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_keyframes-rule_01.js @@ -4,15 +4,14 @@ "use strict"; -// Test that keyframe rules and gutters are displayed correctly in the rule view +// Test that keyframe rules and gutters are displayed correctly in the +// rule view. const TEST_URI = TEST_URL_ROOT + "doc_keyframeanimation.html"; add_task(function*() { yield addTab(TEST_URI); - - let {toolbox, inspector, view} = yield openRuleView(); - + let {inspector, view} = yield openRuleView(); yield testPacman(inspector, view); yield testBoxy(inspector, view); yield testMoxy(inspector, view); @@ -21,18 +20,14 @@ add_task(function*() { function* testPacman(inspector, view) { info("Test content and gutter in the keyframes rule of #pacman"); - let { - rules, - element, - elementStyle - } = yield assertKeyframeRules("#pacman", inspector, view, { + yield assertKeyframeRules("#pacman", inspector, view, { elementRulesNb: 2, keyframeRulesNb: 2, keyframesRules: ["pacman", "pacman"], keyframeRules: ["100%", "100%"] }); - let gutters = assertGutters(view, { + assertGutters(view, { guttersNbs: 2, gutterHeading: ["Keyframes pacman", "Keyframes pacman"] }); @@ -41,18 +36,14 @@ function* testPacman(inspector, view) { function* testBoxy(inspector, view) { info("Test content and gutter in the keyframes rule of #boxy"); - let { - rules, - element, - elementStyle - } = yield assertKeyframeRules("#boxy", inspector, view, { + yield assertKeyframeRules("#boxy", inspector, view, { elementRulesNb: 3, keyframeRulesNb: 3, keyframesRules: ["boxy", "boxy", "boxy"], keyframeRules: ["10%", "20%", "100%"] }); - let gutters = assertGutters(view, { + assertGutters(view, { guttersNbs: 1, gutterHeading: ["Keyframes boxy"] }); @@ -61,18 +52,14 @@ function* testBoxy(inspector, view) { function* testMoxy(inspector, view) { info("Test content and gutter in the keyframes rule of #moxy"); - let { - rules, - element, - elementStyle - } = yield assertKeyframeRules("#moxy", inspector, view, { + yield assertKeyframeRules("#moxy", inspector, view, { elementRulesNb: 3, keyframeRulesNb: 4, keyframesRules: ["boxy", "boxy", "boxy", "moxy"], keyframeRules: ["10%", "20%", "100%", "100%"] }); - let gutters = assertGutters(view, { + assertGutters(view, { guttersNbs: 2, gutterHeading: ["Keyframes boxy", "Keyframes moxy"] }); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_keyframes-rule_02.js b/browser/devtools/styleinspector/test/browser_ruleview_keyframes-rule_02.js index 93f70e815bc2..b9fa4b8c8b0a 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_keyframes-rule_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_keyframes-rule_02.js @@ -5,15 +5,13 @@ "use strict"; // Test that verifies the content of the keyframes rule and property changes -// to keyframe rules +// to keyframe rules. const TEST_URI = TEST_URL_ROOT + "doc_keyframeanimation.html"; add_task(function*() { yield addTab(TEST_URI); - - let {toolbox, inspector, view} = yield openRuleView(); - + let {inspector, view} = yield openRuleView(); yield testPacman(inspector, view); yield testBoxy(inspector, view); }); @@ -21,17 +19,11 @@ add_task(function*() { function* testPacman(inspector, view) { info("Test content in the keyframes rule of #pacman"); - let { - rules, - element, - elementStyle - } = yield getKeyframeRules("#pacman", inspector, view); + let {rules} = yield getKeyframeRules("#pacman", inspector, view); info("Test text properties for Keyframes #pacman"); - is - ( - convertTextPropsToString(rules.keyframeRules[0].textProps), + is(convertTextPropsToString(rules.keyframeRules[0].textProps), "left: 750px", "Keyframe pacman (100%) property is correct" ); @@ -61,31 +53,21 @@ function* testPacman(inspector, view) { function* testBoxy(inspector, view) { info("Test content in the keyframes rule of #boxy"); - let { - rules, - element, - elementStyle - } = yield getKeyframeRules("#boxy", inspector, view); + let {rules} = yield getKeyframeRules("#boxy", inspector, view); info("Test text properties for Keyframes #boxy"); - is - ( - convertTextPropsToString(rules.keyframeRules[0].textProps), + is(convertTextPropsToString(rules.keyframeRules[0].textProps), "background-color: blue", "Keyframe boxy (10%) property is correct" ); - is - ( - convertTextPropsToString(rules.keyframeRules[1].textProps), + is(convertTextPropsToString(rules.keyframeRules[1].textProps), "background-color: green", "Keyframe boxy (20%) property is correct" ); - is - ( - convertTextPropsToString(rules.keyframeRules[2].textProps), + is(convertTextPropsToString(rules.keyframeRules[2].textProps), "opacity: 0", "Keyframe boxy (100%) property is correct" ); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_livepreview.js b/browser/devtools/styleinspector/test/browser_ruleview_livepreview.js index e240e2065341..b7ffa136c7e5 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_livepreview.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_livepreview.js @@ -4,7 +4,16 @@ "use strict"; -// Test that changes are previewed when editing a property value +// Test that changes are previewed when editing a property value. + +const TEST_URI = ` + +
Styled Node
inline element +`; // Format // { @@ -23,13 +32,8 @@ const TEST_DATA = [ ]; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,test rule view live preview on user changes"); - - let style = '#testid {display:block;}'; - let styleNode = addStyle(content.document, style); - content.document.body.innerHTML = '
Styled Node
inline element'; - - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); for (let data of TEST_DATA) { @@ -38,15 +42,15 @@ add_task(function*() { }); function* testLivePreviewData(data, ruleView, selector) { - let testElement = getNode(selector); - let idRuleEditor = getRuleViewRuleEditor(ruleView, 1); - let propEditor = idRuleEditor.rule.textProps[0].editor; + let ruleEditor = getRuleViewRuleEditor(ruleView, 1); + let propEditor = ruleEditor.rule.textProps[0].editor; info("Focusing the property value inplace-editor"); let editor = yield focusEditableField(ruleView, propEditor.valueSpan); - is(inplaceEditor(propEditor.valueSpan), editor, "The focused editor is the value"); + is(inplaceEditor(propEditor.valueSpan), editor, + "The focused editor is the value"); - info("Enter a value in the editor") + info("Enter a value in the editor"); EventUtils.sendString(data.value, ruleView.styleWindow); if (data.escape) { EventUtils.synthesizeKey("VK_ESCAPE", {}); @@ -62,7 +66,8 @@ function* testLivePreviewData(data, ruleView, selector) { } } - // While the editor is still focused in, the display should have changed already + // While the editor is still focused in, the display should have + // changed already is((yield getComputedStyleProperty(selector, null, "display")), data.expected, "Element should be previewed as " + data.expected); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_01.js b/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_01.js index cd33e5603e38..9d09e2c4c466 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_01.js @@ -5,19 +5,19 @@ "use strict"; // Tests that the rule view marks overridden rules correctly based on the -// specificity of the rule +// specificity of the rule. -let TEST_URI = [ - "", - "
Styled Node
" -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_02.js b/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_02.js index 8e93cea2c777..108ea61daf4f 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_02.js @@ -7,17 +7,17 @@ // Tests that the rule view marks overridden rules correctly for short hand // properties and the computed list properties -let TEST_URI = [ - "", - "
Styled Node
" -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_03.js b/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_03.js index 7f5834f1a5f0..aeba17ec0c47 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_03.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_03.js @@ -7,17 +7,17 @@ // Tests that the rule view marks overridden rules correctly based on the // priority for the rule -let TEST_URI = [ - "", - "
Styled Node
" -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_04.js b/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_04.js index 0a5b0cc68120..a2b0f9e6fea5 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_04.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_04.js @@ -7,17 +7,17 @@ // Tests that the rule view marks overridden rules correctly if a property gets // disabled -let TEST_URI = [ - "", - "
Styled Node
" -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_05.js b/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_05.js index 783243a9d704..87db8e522629 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_05.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_mark_overridden_05.js @@ -5,16 +5,16 @@ "use strict"; // Tests that the rule view marks overridden rules correctly based on the -// order of the property +// order of the property. -let TEST_URI = [ - "", - "
Styled Node
" -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_mathml-element.js b/browser/devtools/styleinspector/test/browser_ruleview_mathml-element.js index 288226378299..081a10ba289b 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_mathml-element.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_mathml-element.js @@ -4,30 +4,29 @@ "use strict"; -// Tests that the rule-view displays correctly on MathML elements +// Tests that the rule-view displays correctly on MathML elements. -const TEST_URL = [ - "data:text/html;charset=utf-8,", - "
", - " ", - " ", - " ", - " a", - " i", - " j", - " ", - " ", - " x", - " 0", - " ", - " ", - " ", - "
" -].join(""); +const TEST_URI = ` +
+ + + + a + i + j + + + x + 0 + + + +
+`; add_task(function*() { - yield addTab(TEST_URL); - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); info("Select the DIV node and verify the rule-view shows rules"); yield selectNode("div", inspector); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_media-queries.js b/browser/devtools/styleinspector/test/browser_ruleview_media-queries.js index 0eaebcbdd087..9984999467b1 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_media-queries.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_media-queries.js @@ -12,7 +12,6 @@ const TEST_URI = TEST_URL_ROOT + "doc_media_queries.html"; add_task(function*() { yield addTab(TEST_URI); let {inspector, view} = yield openRuleView(); - yield selectNode("div", inspector); let elementStyle = view._elementStyle; diff --git a/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-duplicates.js b/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-duplicates.js index c8b1df130fe1..589d00293dca 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-duplicates.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-duplicates.js @@ -7,48 +7,60 @@ // Test that the rule-view behaves correctly when entering mutliple and/or // unfinished properties/values in inplace-editors +const TEST_URI = "
Test Element
"; + add_task(function*() { - yield addTab("data:text/html;charset=utf-8,test rule view user changes"); - content.document.body.innerHTML = "

Testing Multiple Properties

"; - let {toolbox, inspector, view} = yield openRuleView(); - - info("Creating the test element"); - let newElement = content.document.createElement("div"); - newElement.textContent = "Test Element"; - content.document.body.appendChild(newElement); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); - let ruleEditor = getRuleViewRuleEditor(view, 0); - - yield testCreateNewMultiDuplicates(inspector, ruleEditor); + yield testCreateNewMultiDuplicates(inspector, view); }); -function* testCreateNewMultiDuplicates(inspector, ruleEditor) { +function* testCreateNewMultiDuplicates(inspector, view) { + let ruleEditor = getRuleViewRuleEditor(view, 0); let onMutation = inspector.once("markupmutation"); yield createNewRuleViewProperty(ruleEditor, - "color:red;color:orange;color:yellow;color:green;color:blue;color:indigo;color:violet;"); + "color:red;color:orange;color:yellow;color:green;color:blue;color:indigo;" + + "color:violet;"); yield onMutation; - is(ruleEditor.rule.textProps.length, 7, "Should have created new text properties."); - is(ruleEditor.propertyList.children.length, 8, "Should have created new property editors."); + is(ruleEditor.rule.textProps.length, 7, + "Should have created new text properties."); + is(ruleEditor.propertyList.children.length, 8, + "Should have created new property editors."); - is(ruleEditor.rule.textProps[0].name, "color", "Should have correct property name"); - is(ruleEditor.rule.textProps[0].value, "red", "Should have correct property value"); + is(ruleEditor.rule.textProps[0].name, "color", + "Should have correct property name"); + is(ruleEditor.rule.textProps[0].value, "red", + "Should have correct property value"); - is(ruleEditor.rule.textProps[1].name, "color", "Should have correct property name"); - is(ruleEditor.rule.textProps[1].value, "orange", "Should have correct property value"); + is(ruleEditor.rule.textProps[1].name, "color", + "Should have correct property name"); + is(ruleEditor.rule.textProps[1].value, "orange", + "Should have correct property value"); - is(ruleEditor.rule.textProps[2].name, "color", "Should have correct property name"); - is(ruleEditor.rule.textProps[2].value, "yellow", "Should have correct property value"); + is(ruleEditor.rule.textProps[2].name, "color", + "Should have correct property name"); + is(ruleEditor.rule.textProps[2].value, "yellow", + "Should have correct property value"); - is(ruleEditor.rule.textProps[3].name, "color", "Should have correct property name"); - is(ruleEditor.rule.textProps[3].value, "green", "Should have correct property value"); + is(ruleEditor.rule.textProps[3].name, "color", + "Should have correct property name"); + is(ruleEditor.rule.textProps[3].value, "green", + "Should have correct property value"); - is(ruleEditor.rule.textProps[4].name, "color", "Should have correct property name"); - is(ruleEditor.rule.textProps[4].value, "blue", "Should have correct property value"); + is(ruleEditor.rule.textProps[4].name, "color", + "Should have correct property name"); + is(ruleEditor.rule.textProps[4].value, "blue", + "Should have correct property value"); - is(ruleEditor.rule.textProps[5].name, "color", "Should have correct property name"); - is(ruleEditor.rule.textProps[5].value, "indigo", "Should have correct property value"); + is(ruleEditor.rule.textProps[5].name, "color", + "Should have correct property name"); + is(ruleEditor.rule.textProps[5].value, "indigo", + "Should have correct property value"); - is(ruleEditor.rule.textProps[6].name, "color", "Should have correct property name"); - is(ruleEditor.rule.textProps[6].value, "violet", "Should have correct property value"); + is(ruleEditor.rule.textProps[6].name, "color", + "Should have correct property name"); + is(ruleEditor.rule.textProps[6].value, "violet", + "Should have correct property value"); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-priority.js b/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-priority.js index aab1cb74aa62..186db8266811 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-priority.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-priority.js @@ -5,38 +5,41 @@ "use strict"; // Test that the rule-view behaves correctly when entering mutliple and/or -// unfinished properties/values in inplace-editors +// unfinished properties/values in inplace-editors. + +const TEST_URI = "
Test Element
"; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,test rule view user changes"); - content.document.body.innerHTML = "

Testing Multiple Properties

"; - let {toolbox, inspector, view} = yield openRuleView(); - - info("Creating the test element"); - let newElement = content.document.createElement("div"); - newElement.textContent = "Test Element"; - content.document.body.appendChild(newElement); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); - let ruleEditor = getRuleViewRuleEditor(view, 0); - - yield testCreateNewMultiPriority(inspector, ruleEditor); + yield testCreateNewMultiPriority(inspector, view); }); -function* testCreateNewMultiPriority(inspector, ruleEditor) { +function* testCreateNewMultiPriority(inspector, view) { + let ruleEditor = getRuleViewRuleEditor(view, 0); let onMutation = inspector.once("markupmutation"); yield createNewRuleViewProperty(ruleEditor, "color:red;width:100px;height: 100px;"); yield onMutation; - is(ruleEditor.rule.textProps.length, 3, "Should have created new text properties."); - is(ruleEditor.propertyList.children.length, 4, "Should have created new property editors."); + is(ruleEditor.rule.textProps.length, 3, + "Should have created new text properties."); + is(ruleEditor.propertyList.children.length, 4, + "Should have created new property editors."); - is(ruleEditor.rule.textProps[0].name, "color", "Should have correct property name"); - is(ruleEditor.rule.textProps[0].value, "red", "Should have correct property value"); + is(ruleEditor.rule.textProps[0].name, "color", + "Should have correct property name"); + is(ruleEditor.rule.textProps[0].value, "red", + "Should have correct property value"); - is(ruleEditor.rule.textProps[1].name, "width", "Should have correct property name"); - is(ruleEditor.rule.textProps[1].value, "100px", "Should have correct property value"); + is(ruleEditor.rule.textProps[1].name, "width", + "Should have correct property name"); + is(ruleEditor.rule.textProps[1].value, "100px", + "Should have correct property value"); - is(ruleEditor.rule.textProps[2].name, "height", "Should have correct property name"); - is(ruleEditor.rule.textProps[2].value, "100px", "Should have correct property value"); + is(ruleEditor.rule.textProps[2].name, "height", + "Should have correct property name"); + is(ruleEditor.rule.textProps[2].value, "100px", + "Should have correct property value"); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-unfinished_01.js b/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-unfinished_01.js index f0bcdd62f840..a4a764a68dc1 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-unfinished_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-unfinished_01.js @@ -7,34 +7,29 @@ // Test that the rule-view behaves correctly when entering mutliple and/or // unfinished properties/values in inplace-editors +const TEST_URI = "
Test Element
"; + add_task(function*() { - yield addTab("data:text/html;charset=utf-8,test rule view user changes"); - content.document.body.innerHTML = "

Testing Multiple Properties

"; - let {toolbox, inspector, view} = yield openRuleView(); - - info("Creating the test element"); - let newElement = content.document.createElement("div"); - newElement.textContent = "Test Element"; - content.document.body.appendChild(newElement); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); - let ruleEditor = getRuleViewRuleEditor(view, 0); - - yield testCreateNewMultiUnfinished(inspector, ruleEditor, view); + yield testCreateNewMultiUnfinished(inspector, view); }); function waitRuleViewChanged(view, n) { let deferred = promise.defer(); let count = 0; - let listener = function () { + let listener = function() { if (++count == n) { view.off("ruleview-changed", listener); deferred.resolve(); } - } + }; view.on("ruleview-changed", listener); return deferred.promise; } -function* testCreateNewMultiUnfinished(inspector, ruleEditor, view) { +function* testCreateNewMultiUnfinished(inspector, view) { + let ruleEditor = getRuleViewRuleEditor(view, 0); let onMutation = inspector.once("markupmutation"); // There is 5 rule-view updates, one for the rule view creation, // one for each new property @@ -44,26 +39,38 @@ function* testCreateNewMultiUnfinished(inspector, ruleEditor, view) { yield onMutation; yield onRuleViewChanged; - is(ruleEditor.rule.textProps.length, 4, "Should have created new text properties."); - is(ruleEditor.propertyList.children.length, 4, "Should have created property editors."); + is(ruleEditor.rule.textProps.length, 4, + "Should have created new text properties."); + is(ruleEditor.propertyList.children.length, 4, + "Should have created property editors."); EventUtils.sendString("red", view.styleWindow); onRuleViewChanged = view.once("ruleview-changed"); EventUtils.synthesizeKey("VK_RETURN", {}, view.styleWindow); yield onRuleViewChanged; - is(ruleEditor.rule.textProps.length, 4, "Should have the same number of text properties."); - is(ruleEditor.propertyList.children.length, 5, "Should have added the changed value editor."); + is(ruleEditor.rule.textProps.length, 4, + "Should have the same number of text properties."); + is(ruleEditor.propertyList.children.length, 5, + "Should have added the changed value editor."); - is(ruleEditor.rule.textProps[0].name, "color", "Should have correct property name"); - is(ruleEditor.rule.textProps[0].value, "blue", "Should have correct property value"); + is(ruleEditor.rule.textProps[0].name, "color", + "Should have correct property name"); + is(ruleEditor.rule.textProps[0].value, "blue", + "Should have correct property value"); - is(ruleEditor.rule.textProps[1].name, "background", "Should have correct property name"); - is(ruleEditor.rule.textProps[1].value, "orange", "Should have correct property value"); + is(ruleEditor.rule.textProps[1].name, "background", + "Should have correct property name"); + is(ruleEditor.rule.textProps[1].value, "orange", + "Should have correct property value"); - is(ruleEditor.rule.textProps[2].name, "text-align", "Should have correct property name"); - is(ruleEditor.rule.textProps[2].value, "center", "Should have correct property value"); + is(ruleEditor.rule.textProps[2].name, "text-align", + "Should have correct property name"); + is(ruleEditor.rule.textProps[2].value, "center", + "Should have correct property value"); - is(ruleEditor.rule.textProps[3].name, "border-color", "Should have correct property name"); - is(ruleEditor.rule.textProps[3].value, "red", "Should have correct property value"); + is(ruleEditor.rule.textProps[3].name, "border-color", + "Should have correct property name"); + is(ruleEditor.rule.textProps[3].value, "red", + "Should have correct property value"); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-unfinished_02.js b/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-unfinished_02.js index f8436304923a..6099bbb3db8e 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-unfinished_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_multiple-properties-unfinished_02.js @@ -7,28 +7,25 @@ // Test that the rule-view behaves correctly when entering mutliple and/or // unfinished properties/values in inplace-editors +const TEST_URI = "
Test Element
"; + add_task(function*() { - yield addTab("data:text/html;charset=utf-8,test rule view user changes"); - content.document.body.innerHTML = "

Testing Multiple Properties

"; - let {toolbox, inspector, view} = yield openRuleView(); - - info("Creating the test element"); - let newElement = content.document.createElement("div"); - newElement.textContent = "Test Element"; - content.document.body.appendChild(newElement); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); - let ruleEditor = getRuleViewRuleEditor(view, 0); - - yield testCreateNewMultiPartialUnfinished(inspector, ruleEditor, view); + yield testCreateNewMultiPartialUnfinished(inspector, view); }); -function* testCreateNewMultiPartialUnfinished(inspector, ruleEditor, view) { +function* testCreateNewMultiPartialUnfinished(inspector, view) { + let ruleEditor = getRuleViewRuleEditor(view, 0); let onMutation = inspector.once("markupmutation"); yield createNewRuleViewProperty(ruleEditor, "width: 100px; heig"); yield onMutation; - is(ruleEditor.rule.textProps.length, 2, "Should have created a new text property."); - is(ruleEditor.propertyList.children.length, 2, "Should have created a property editor."); + is(ruleEditor.rule.textProps.length, 2, + "Should have created a new text property."); + is(ruleEditor.propertyList.children.length, 2, + "Should have created a property editor."); // Value is focused, lets add multiple rules here and make sure they get added onMutation = inspector.once("markupmutation"); @@ -37,18 +34,28 @@ function* testCreateNewMultiPartialUnfinished(inspector, ruleEditor, view) { EventUtils.synthesizeKey("VK_RETURN", {}, view.styleWindow); yield onMutation; - is(ruleEditor.rule.textProps.length, 4, "Should have added the changed value."); - is(ruleEditor.propertyList.children.length, 5, "Should have added the changed value editor."); + is(ruleEditor.rule.textProps.length, 4, + "Should have added the changed value."); + is(ruleEditor.propertyList.children.length, 5, + "Should have added the changed value editor."); - is(ruleEditor.rule.textProps[0].name, "width", "Should have correct property name"); - is(ruleEditor.rule.textProps[0].value, "100px", "Should have correct property value"); + is(ruleEditor.rule.textProps[0].name, "width", + "Should have correct property name"); + is(ruleEditor.rule.textProps[0].value, "100px", + "Should have correct property value"); - is(ruleEditor.rule.textProps[1].name, "heig", "Should have correct property name"); - is(ruleEditor.rule.textProps[1].value, "10px", "Should have correct property value"); + is(ruleEditor.rule.textProps[1].name, "heig", + "Should have correct property name"); + is(ruleEditor.rule.textProps[1].value, "10px", + "Should have correct property value"); - is(ruleEditor.rule.textProps[2].name, "background", "Should have correct property name"); - is(ruleEditor.rule.textProps[2].value, "orangered", "Should have correct property value"); + is(ruleEditor.rule.textProps[2].name, "background", + "Should have correct property name"); + is(ruleEditor.rule.textProps[2].value, "orangered", + "Should have correct property value"); - is(ruleEditor.rule.textProps[3].name, "color", "Should have correct property name"); - is(ruleEditor.rule.textProps[3].value, "black", "Should have correct property value"); + is(ruleEditor.rule.textProps[3].name, "color", + "Should have correct property name"); + is(ruleEditor.rule.textProps[3].value, "black", + "Should have correct property value"); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_multiple_properties_01.js b/browser/devtools/styleinspector/test/browser_ruleview_multiple_properties_01.js index 88c7a20da728..f6133cd2df3a 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_multiple_properties_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_multiple_properties_01.js @@ -5,41 +5,47 @@ "use strict"; // Test that the rule-view behaves correctly when entering mutliple and/or -// unfinished properties/values in inplace-editors +// unfinished properties/values in inplace-editors. + +const TEST_URI = "
Test Element
"; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,test rule view user changes"); - content.document.body.innerHTML = "

Testing Multiple Properties

"; - let {toolbox, inspector, view} = yield openRuleView(); - - info("Creating the test element"); - let newElement = content.document.createElement("div"); - newElement.textContent = "Test Element"; - content.document.body.appendChild(newElement); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); - let ruleEditor = getRuleViewRuleEditor(view, 0); - - yield testCreateNewMulti(inspector, ruleEditor); + yield testCreateNewMulti(inspector, view); }); -function* testCreateNewMulti(inspector, ruleEditor) { +function* testCreateNewMulti(inspector, view) { + let ruleEditor = getRuleViewRuleEditor(view, 0); let onMutation = inspector.once("markupmutation"); yield createNewRuleViewProperty(ruleEditor, - "color:blue;background : orange ; text-align:center; border-color: green;"); + "color:blue;background : orange ; text-align:center; " + + "border-color: green;"); yield onMutation; - is(ruleEditor.rule.textProps.length, 4, "Should have created a new text property."); - is(ruleEditor.propertyList.children.length, 5, "Should have created a new property editor."); + is(ruleEditor.rule.textProps.length, 4, + "Should have created a new text property."); + is(ruleEditor.propertyList.children.length, 5, + "Should have created a new property editor."); - is(ruleEditor.rule.textProps[0].name, "color", "Should have correct property name"); - is(ruleEditor.rule.textProps[0].value, "blue", "Should have correct property value"); + is(ruleEditor.rule.textProps[0].name, "color", + "Should have correct property name"); + is(ruleEditor.rule.textProps[0].value, "blue", + "Should have correct property value"); - is(ruleEditor.rule.textProps[1].name, "background", "Should have correct property name"); - is(ruleEditor.rule.textProps[1].value, "orange", "Should have correct property value"); + is(ruleEditor.rule.textProps[1].name, "background", + "Should have correct property name"); + is(ruleEditor.rule.textProps[1].value, "orange", + "Should have correct property value"); - is(ruleEditor.rule.textProps[2].name, "text-align", "Should have correct property name"); - is(ruleEditor.rule.textProps[2].value, "center", "Should have correct property value"); + is(ruleEditor.rule.textProps[2].name, "text-align", + "Should have correct property name"); + is(ruleEditor.rule.textProps[2].value, "center", + "Should have correct property value"); - is(ruleEditor.rule.textProps[3].name, "border-color", "Should have correct property name"); - is(ruleEditor.rule.textProps[3].value, "green", "Should have correct property value"); + is(ruleEditor.rule.textProps[3].name, "border-color", + "Should have correct property name"); + is(ruleEditor.rule.textProps[3].value, "green", + "Should have correct property value"); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_multiple_properties_02.js b/browser/devtools/styleinspector/test/browser_ruleview_multiple_properties_02.js index 7a3d17b348b0..465db00a24df 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_multiple_properties_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_multiple_properties_02.js @@ -7,43 +7,47 @@ // Test that the rule-view behaves correctly when entering mutliple and/or // unfinished properties/values in inplace-editors +const TEST_URI = "
Test Element
"; + add_task(function*() { - yield addTab("data:text/html;charset=utf-8,test rule view user changes"); - content.document.body.innerHTML = "

Testing Multiple Properties

"; - let {toolbox, inspector, view} = yield openRuleView(); - - info("Creating the test element"); - let newElement = content.document.createElement("div"); - newElement.textContent = "Test Element"; - content.document.body.appendChild(newElement); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); - let ruleEditor = getRuleViewRuleEditor(view, 0); - - yield testMultiValues(inspector, ruleEditor, view); + yield testMultiValues(inspector, view); }); -function* testMultiValues(inspector, ruleEditor, view) { +function* testMultiValues(inspector, view) { + let ruleEditor = getRuleViewRuleEditor(view, 0); yield createNewRuleViewProperty(ruleEditor, "width:"); - is(ruleEditor.rule.textProps.length, 1, "Should have created a new text property."); - is(ruleEditor.propertyList.children.length, 1, "Should have created a property editor."); + is(ruleEditor.rule.textProps.length, 1, + "Should have created a new text property."); + is(ruleEditor.propertyList.children.length, 1, + "Should have created a property editor."); // Value is focused, lets add multiple rules here and make sure they get added let onMutation = inspector.once("markupmutation"); let valueEditor = ruleEditor.propertyList.children[0].querySelector("input"); - valueEditor.value = "height: 10px;color:blue" + valueEditor.value = "height: 10px;color:blue"; EventUtils.synthesizeKey("VK_RETURN", {}, view.styleWindow); yield onMutation; - is(ruleEditor.rule.textProps.length, 2, "Should have added the changed value."); - is(ruleEditor.propertyList.children.length, 3, "Should have added the changed value editor."); + is(ruleEditor.rule.textProps.length, 2, + "Should have added the changed value."); + is(ruleEditor.propertyList.children.length, 3, + "Should have added the changed value editor."); EventUtils.synthesizeKey("VK_ESCAPE", {}, view.styleWindow); - is(ruleEditor.propertyList.children.length, 2, "Should have removed the value editor."); + is(ruleEditor.propertyList.children.length, 2, + "Should have removed the value editor."); - is(ruleEditor.rule.textProps[0].name, "width", "Should have correct property name"); - is(ruleEditor.rule.textProps[0].value, "height: 10px", "Should have correct property value"); + is(ruleEditor.rule.textProps[0].name, "width", + "Should have correct property name"); + is(ruleEditor.rule.textProps[0].value, "height: 10px", + "Should have correct property value"); - is(ruleEditor.rule.textProps[1].name, "color", "Should have correct property name"); - is(ruleEditor.rule.textProps[1].value, "blue", "Should have correct property value"); + is(ruleEditor.rule.textProps[1].name, "color", + "Should have correct property name"); + is(ruleEditor.rule.textProps[1].value, "blue", + "Should have correct property value"); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_original-source-link.js b/browser/devtools/styleinspector/test/browser_ruleview_original-source-link.js index 4baa84df304a..2ce2f3c217ce 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_original-source-link.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_original-source-link.js @@ -5,7 +5,7 @@ "use strict"; // Test that the stylesheet links in the rule view are correct when source maps -// are involved +// are involved. const TESTCASE_URI = TEST_URL_ROOT + "doc_sourcemaps.html"; const PREF = "devtools.styleeditor.source-maps-enabled"; @@ -13,10 +13,9 @@ const SCSS_LOC = "doc_sourcemaps.scss:4"; const CSS_LOC = "doc_sourcemaps.css:1"; add_task(function*() { - info("Setting the " + PREF + " pref to true"); + info("Setting the " + PREF + " pref to true"); Services.prefs.setBoolPref(PREF, true); - info("Opening the test page and opening the inspector"); yield addTab(TESTCASE_URI); let {toolbox, inspector, view} = yield openRuleView(); @@ -59,7 +58,8 @@ function checkDisplayedStylesheet(toolbox) { // selecting the desired sheet. if (editor.styleSheet.href.endsWith("scss")) { info("Original source editor selected"); - editor.getSourceEditor().then(editorSelected).then(def.resolve, def.reject); + editor.getSourceEditor().then(editorSelected) + .then(def.resolve, def.reject); } }); @@ -68,9 +68,10 @@ function checkDisplayedStylesheet(toolbox) { function editorSelected(editor) { let href = editor.styleSheet.href; - ok(href.endsWith("doc_sourcemaps.scss"), "selected stylesheet is correct one"); + ok(href.endsWith("doc_sourcemaps.scss"), + "selected stylesheet is correct one"); - let {line, col} = editor.sourceEditor.getCursor(); + let {line} = editor.sourceEditor.getCursor(); is(line, 3, "cursor is at correct line number in original source"); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_pseudo-element_01.js b/browser/devtools/styleinspector/test/browser_ruleview_pseudo-element_01.js index 1d4ed0627541..f7d267fae233 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_pseudo-element_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_pseudo-element_01.js @@ -27,12 +27,14 @@ add_task(function*() { function* testTopLeft(inspector, view) { let selector = "#topleft"; - let {rules} = yield assertPseudoElementRulesNumbers(selector, inspector, view, { - elementRulesNb: 4, - firstLineRulesNb: 2, - firstLetterRulesNb: 1, - selectionRulesNb: 0 - }); + let {rules} = yield assertPseudoElementRulesNumbers(selector, + inspector, view, { + elementRulesNb: 4, + firstLineRulesNb: 2, + firstLetterRulesNb: 1, + selectionRulesNb: 0 + } + ); let gutters = assertGutters(view); @@ -68,8 +70,10 @@ function* testTopLeft(inspector, view) { "color: orange", "TopLeft firstLine properties are correct"); - let firstProp = elementFirstLineRuleView.addProperty("background-color", "rgb(0, 255, 0)", ""); - let secondProp = elementFirstLineRuleView.addProperty("font-style", "italic", ""); + let firstProp = elementFirstLineRuleView.addProperty("background-color", + "rgb(0, 255, 0)", ""); + let secondProp = elementFirstLineRuleView.addProperty("font-style", + "italic", ""); is(firstProp, elementFirstLineRule.textProps[elementFirstLineRule.textProps.length - 2], @@ -199,9 +203,12 @@ function* assertPseudoElementRulesNumbers(selector, inspector, view, ruleNbs) { let rules = { elementRules: elementStyle.rules.filter(rule => !rule.pseudoElement), - firstLineRules: elementStyle.rules.filter(rule => rule.pseudoElement === ":first-line"), - firstLetterRules: elementStyle.rules.filter(rule => rule.pseudoElement === ":first-letter"), - selectionRules: elementStyle.rules.filter(rule => rule.pseudoElement === ":-moz-selection") + firstLineRules: elementStyle.rules.filter(rule => + rule.pseudoElement === ":first-line"), + firstLetterRules: elementStyle.rules.filter(rule => + rule.pseudoElement === ":first-letter"), + selectionRules: elementStyle.rules.filter(rule => + rule.pseudoElement === ":-moz-selection") }; is(rules.elementRules.length, ruleNbs.elementRulesNb, diff --git a/browser/devtools/styleinspector/test/browser_ruleview_pseudo-element_02.js b/browser/devtools/styleinspector/test/browser_ruleview_pseudo-element_02.js index 9188898166c5..c1e110b01162 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_pseudo-element_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_pseudo-element_02.js @@ -10,23 +10,24 @@ const TEST_URI = TEST_URL_ROOT + "doc_pseudoelement.html"; add_task(function*() { yield addTab(TEST_URI); - let {toolbox, inspector, view} = yield openRuleView(); - - yield testTopLeft(inspector, view); + let {inspector} = yield openRuleView(); + yield testTopLeft(inspector); }); -function* testTopLeft(inspector, view) { +function* testTopLeft(inspector) { let node = inspector.markup.walker.frontForRawNode(getNode("#topleft")); let children = yield inspector.markup.walker.children(node); - is (children.nodes.length, 3, "Element has correct number of children"); + is(children.nodes.length, 3, "Element has correct number of children"); let beforeElement = children.nodes[0]; - is (beforeElement.tagName, "_moz_generated_content_before", "tag name is correct"); + is(beforeElement.tagName, "_moz_generated_content_before", + "tag name is correct"); yield selectNode(beforeElement, inspector); - let afterElement = children.nodes[children.nodes.length-1]; - is (afterElement.tagName, "_moz_generated_content_after", "tag name is correct"); + let afterElement = children.nodes[children.nodes.length - 1]; + is(afterElement.tagName, "_moz_generated_content_after", + "tag name is correct"); yield selectNode(afterElement, inspector); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_pseudo_lock_options.js b/browser/devtools/styleinspector/test/browser_ruleview_pseudo_lock_options.js index 0275727f991c..85e99bdd30c8 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_pseudo_lock_options.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_pseudo_lock_options.js @@ -6,23 +6,23 @@ // Tests that the rule view pseudo lock options work properly. -let TEST_URI = [ - "", - "
test div
" -].join("\n"); +const TEST_URI = ` + +
test div
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_refresh-on-attribute-change_01.js b/browser/devtools/styleinspector/test/browser_ruleview_refresh-on-attribute-change_01.js index a91e3a4c0a65..0331cfa20478 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_refresh-on-attribute-change_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_refresh-on-attribute-change_01.js @@ -6,30 +6,32 @@ // Test that changing the current element's attributes refreshes the rule-view +const TEST_URI = ` + +
+ Styled Node +
+`; + add_task(function*() { - yield addTab("data:text/html;charset=utf-8,browser_ruleview_refresh-on-attribute-change.js"); - - info("Preparing the test document and node"); - let style = '' + - '#testid {' + - ' background-color: blue;' + - '} ' + - '.testclass {' + - ' background-color: green;' + - '}'; - let styleNode = addStyle(content.document, style); - content.document.body.innerHTML = '
Styled Node
'; + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); let testElement = getNode("#testid"); - let elementStyle = 'margin-top: 1px; padding-top: 5px;' - testElement.setAttribute("style", elementStyle); - - let {toolbox, inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); - info("Checking that the rule-view has the element, #testid and .testclass selectors"); + info("Checking that the rule-view has the element, #testid and " + + ".testclass selectors"); checkRuleViewContent(view, ["element", "#testid", ".testclass"]); - info("Changing the node's ID attribute and waiting for the rule-view refresh"); + info("Changing the node's ID attribute and waiting for the " + + "rule-view refresh"); let ruleViewRefreshed = inspector.once("rule-view-refreshed"); testElement.setAttribute("id", "differentid"); yield ruleViewRefreshed; @@ -47,12 +49,13 @@ add_task(function*() { }); function checkRuleViewContent(view, expectedSelectors) { - let selectors = view.styleDocument.querySelectorAll(".ruleview-selectorcontainer"); + let selectors = view.styleDocument + .querySelectorAll(".ruleview-selectorcontainer"); is(selectors.length, expectedSelectors.length, expectedSelectors.length + " selectors are displayed"); - for (let i = 0; i < expectedSelectors.length; i ++) { + for (let i = 0; i < expectedSelectors.length; i++) { is(selectors[i].textContent.indexOf(expectedSelectors[i]), 0, "Selector " + (i + 1) + " is " + expectedSelectors[i]); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_refresh-on-attribute-change_02.js b/browser/devtools/styleinspector/test/browser_ruleview_refresh-on-attribute-change_02.js index 26017aac438b..06370efc2863 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_refresh-on-attribute-change_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_refresh-on-attribute-change_02.js @@ -4,19 +4,22 @@ "use strict"; -// Test that changing the current element's style attribute refreshes the rule-view +// Test that changing the current element's style attribute refreshes the +// rule-view + +const TEST_URI = ` +
+ Styled Node +
+`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,browser_ruleview_update.js"); - - content.document.body.innerHTML = '
Styled Node
'; + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); let testElement = getNode("#testid"); - testElement.setAttribute("style", "margin-top: 1px; padding-top: 5px;"); - - let {toolbox, inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); - yield testPropertyChanges(inspector, view, testElement); + yield testPropertyChanges(inspector, view); yield testPropertyChange0(inspector, view, testElement); yield testPropertyChange1(inspector, view, testElement); yield testPropertyChange2(inspector, view, testElement); @@ -26,7 +29,7 @@ add_task(function*() { yield testPropertyChange6(inspector, view, testElement); }); -function* testPropertyChanges(inspector, ruleView, testElement) { +function* testPropertyChanges(inspector, ruleView) { info("Adding a second margin-top value in the element selector"); let ruleEditor = ruleView._elementStyle.rules[0].editor; let onRefreshed = inspector.once("rule-view-refreshed"); @@ -34,72 +37,98 @@ function* testPropertyChanges(inspector, ruleView, testElement) { yield onRefreshed; let rule = ruleView._elementStyle.rules[0]; - validateTextProp(rule.textProps[0], false, "margin-top", "1px", "Original margin property active"); + validateTextProp(rule.textProps[0], false, "margin-top", "1px", + "Original margin property active"); } function* testPropertyChange0(inspector, ruleView, testElement) { - yield changeElementStyle(testElement, "margin-top: 1px; padding-top: 5px", inspector); + yield changeElementStyle(testElement, "margin-top: 1px; padding-top: 5px", + inspector); let rule = ruleView._elementStyle.rules[0]; - is(rule.editor.element.querySelectorAll(".ruleview-property").length, 3, "Correct number of properties"); - validateTextProp(rule.textProps[0], true, "margin-top", "1px", "First margin property re-enabled"); - validateTextProp(rule.textProps[2], false, "margin-top", "5px", "Second margin property disabled"); + is(rule.editor.element.querySelectorAll(".ruleview-property").length, 3, + "Correct number of properties"); + validateTextProp(rule.textProps[0], true, "margin-top", "1px", + "First margin property re-enabled"); + validateTextProp(rule.textProps[2], false, "margin-top", "5px", + "Second margin property disabled"); } function* testPropertyChange1(inspector, ruleView, testElement) { info("Now set it back to 5px, the 5px value should be re-enabled."); - yield changeElementStyle(testElement, "margin-top: 5px; padding-top: 5px;", inspector); + yield changeElementStyle(testElement, "margin-top: 5px; padding-top: 5px;", + inspector); let rule = ruleView._elementStyle.rules[0]; - is(rule.editor.element.querySelectorAll(".ruleview-property").length, 3, "Correct number of properties"); - validateTextProp(rule.textProps[0], false, "margin-top", "1px", "First margin property re-enabled"); - validateTextProp(rule.textProps[2], true, "margin-top", "5px", "Second margin property disabled"); + is(rule.editor.element.querySelectorAll(".ruleview-property").length, 3, + "Correct number of properties"); + validateTextProp(rule.textProps[0], false, "margin-top", "1px", + "First margin property re-enabled"); + validateTextProp(rule.textProps[2], true, "margin-top", "5px", + "Second margin property disabled"); } function* testPropertyChange2(inspector, ruleView, testElement) { info("Set the margin property to a value that doesn't exist in the editor."); info("Should reuse the currently-enabled element (the second one.)"); - yield changeElementStyle(testElement, "margin-top: 15px; padding-top: 5px;", inspector); + yield changeElementStyle(testElement, "margin-top: 15px; padding-top: 5px;", + inspector); let rule = ruleView._elementStyle.rules[0]; - is(rule.editor.element.querySelectorAll(".ruleview-property").length, 3, "Correct number of properties"); - validateTextProp(rule.textProps[0], false, "margin-top", "1px", "First margin property re-enabled"); - validateTextProp(rule.textProps[2], true, "margin-top", "15px", "Second margin property disabled"); + is(rule.editor.element.querySelectorAll(".ruleview-property").length, 3, + "Correct number of properties"); + validateTextProp(rule.textProps[0], false, "margin-top", "1px", + "First margin property re-enabled"); + validateTextProp(rule.textProps[2], true, "margin-top", "15px", + "Second margin property disabled"); } function* testPropertyChange3(inspector, ruleView, testElement) { - info("Remove the padding-top attribute. Should disable the padding property but not remove it."); + info("Remove the padding-top attribute. Should disable the padding " + + "property but not remove it."); yield changeElementStyle(testElement, "margin-top: 5px;", inspector); let rule = ruleView._elementStyle.rules[0]; - is(rule.editor.element.querySelectorAll(".ruleview-property").length, 3, "Correct number of properties"); - validateTextProp(rule.textProps[1], false, "padding-top", "5px", "Padding property disabled"); + is(rule.editor.element.querySelectorAll(".ruleview-property").length, 3, + "Correct number of properties"); + validateTextProp(rule.textProps[1], false, "padding-top", "5px", + "Padding property disabled"); } function* testPropertyChange4(inspector, ruleView, testElement) { - info("Put the padding-top attribute back in, should re-enable the padding property."); - yield changeElementStyle(testElement, "margin-top: 5px; padding-top: 25px", inspector); + info("Put the padding-top attribute back in, should re-enable the " + + "padding property."); + yield changeElementStyle(testElement, "margin-top: 5px; padding-top: 25px", + inspector); let rule = ruleView._elementStyle.rules[0]; - is(rule.editor.element.querySelectorAll(".ruleview-property").length, 3, "Correct number of properties"); - validateTextProp(rule.textProps[1], true, "padding-top", "25px", "Padding property enabled"); + is(rule.editor.element.querySelectorAll(".ruleview-property").length, 3, + "Correct number of properties"); + validateTextProp(rule.textProps[1], true, "padding-top", "25px", + "Padding property enabled"); } function* testPropertyChange5(inspector, ruleView, testElement) { info("Add an entirely new property"); - yield changeElementStyle(testElement, "margin-top: 5px; padding-top: 25px; padding-left: 20px;", inspector); + yield changeElementStyle(testElement, + "margin-top: 5px; padding-top: 25px; padding-left: 20px;", inspector); let rule = ruleView._elementStyle.rules[0]; - is(rule.editor.element.querySelectorAll(".ruleview-property").length, 4, "Added a property"); - validateTextProp(rule.textProps[3], true, "padding-left", "20px", "Padding property enabled"); + is(rule.editor.element.querySelectorAll(".ruleview-property").length, 4, + "Added a property"); + validateTextProp(rule.textProps[3], true, "padding-left", "20px", + "Padding property enabled"); } function* testPropertyChange6(inspector, ruleView, testElement) { info("Add an entirely new property again"); - yield changeElementStyle(testElement, "background: red url(\"chrome://branding/content/about-logo.png\") repeat scroll 0% 0%", inspector); + yield changeElementStyle(testElement, "background: red " + + "url(\"chrome://branding/content/about-logo.png\") repeat scroll 0% 0%", + inspector); let rule = ruleView._elementStyle.rules[0]; - is(rule.editor.element.querySelectorAll(".ruleview-property").length, 5, "Added a property"); + is(rule.editor.element.querySelectorAll(".ruleview-property").length, 5, + "Added a property"); validateTextProp(rule.textProps[4], true, "background", "red url(\"chrome://branding/content/about-logo.png\") repeat scroll 0% 0%", "shortcut property correctly set", @@ -112,12 +141,15 @@ function* changeElementStyle(testElement, style, inspector) { yield onRefreshed; } -function validateTextProp(aProp, aEnabled, aName, aValue, aDesc, valueSpanText) { +function validateTextProp(aProp, aEnabled, aName, aValue, aDesc, + valueSpanText) { is(aProp.enabled, aEnabled, aDesc + ": enabled."); is(aProp.name, aName, aDesc + ": name."); is(aProp.value, aValue, aDesc + ": value."); - is(aProp.editor.enable.hasAttribute("checked"), aEnabled, aDesc + ": enabled checkbox."); + is(aProp.editor.enable.hasAttribute("checked"), aEnabled, + aDesc + ": enabled checkbox."); is(aProp.editor.nameSpan.textContent, aName, aDesc + ": name span."); - is(aProp.editor.valueSpan.textContent, valueSpanText || aValue, aDesc + ": value span."); + is(aProp.editor.valueSpan.textContent, + valueSpanText || aValue, aDesc + ": value span."); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_refresh-on-style-change.js b/browser/devtools/styleinspector/test/browser_ruleview_refresh-on-style-change.js index 7813ac927ebd..b4ad2664be9b 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_refresh-on-style-change.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_refresh-on-style-change.js @@ -7,19 +7,13 @@ // Test that the rule view refreshes when the current node has its style // changed -const TESTCASE_URI = 'data:text/html;charset=utf-8,' + - '
Test div!
'; +const TEST_URI = "
Test div!
"; add_task(function*() { - yield addTab(TESTCASE_URI); - Services.prefs.setCharPref("devtools.defaultColorUnit", "name"); - info("Getting the test node"); - let div = getNode("#testdiv"); - - info("Opening the rule view and selecting the test node"); - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("#testdiv", inspector); let fontSize = getRuleViewPropertyValue(view, "element", "font-size"); @@ -27,15 +21,18 @@ add_task(function*() { info("Changing the node's style and waiting for the update"); let onUpdated = inspector.once("rule-view-refreshed"); - div.style.cssText = "font-size: 3em; color: lightgoldenrodyellow; text-align: right; text-transform: uppercase"; + let div = getNode("#testdiv"); + div.style.cssText = "font-size: 3em; color: lightgoldenrodyellow; " + + "text-align: right; text-transform: uppercase"; yield onUpdated; let textAlign = getRuleViewPropertyValue(view, "element", "text-align"); is(textAlign, "right", "The rule view shows the new text align."); let color = getRuleViewPropertyValue(view, "element", "color"); - is(color, "lightgoldenrodyellow", "The rule view shows the new color.") + is(color, "lightgoldenrodyellow", "The rule view shows the new color."); fontSize = getRuleViewPropertyValue(view, "element", "font-size"); is(fontSize, "3em", "The rule view shows the new font size."); - let textTransform = getRuleViewPropertyValue(view, "element", "text-transform"); + let textTransform = getRuleViewPropertyValue(view, "element", + "text-transform"); is(textTransform, "uppercase", "The rule view shows the new text transform."); }); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_01.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_01.js index dee38bf40556..efcc9a5bd81e 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_01.js @@ -7,23 +7,23 @@ // Tests that the rule view search filter works properly in the computed list // for property values. -const SEARCH = "0px" +const SEARCH = "0px"; -let TEST_URI = [ - '', - '

Styled Node

' -].join("\n"); +const TEST_URI = ` + +

Styled Node

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); }); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_02.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_02.js index ac11eb887071..80ab205a8105 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_02.js @@ -7,23 +7,23 @@ // Tests that the rule view search filter works properly in the computed list // for property names. -const SEARCH = "margin" +const SEARCH = "margin"; -let TEST_URI = [ - '', - '

Styled Node

' -].join("\n"); +const TEST_URI = ` + +

Styled Node

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); }); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_03.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_03.js index 204966da0833..1bb8118c4b78 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_03.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_03.js @@ -7,23 +7,23 @@ // Tests that the rule view search filter works properly in the computed list // for property line input. -const SEARCH = "margin-top:4px" +const SEARCH = "margin-top:4px"; -let TEST_URI = [ - '', - '

Styled Node

' -].join("\n"); +const TEST_URI = ` + +

Styled Node

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); }); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_04.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_04.js index dc20906459bb..58873f155990 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_04.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_04.js @@ -7,23 +7,23 @@ // Tests that the rule view search filter works properly in the computed list // for parsed property value. -const SEARCH = ":4px" +const SEARCH = ":4px"; -let TEST_URI = [ - '', - '

Styled Node

' -].join("\n"); +const TEST_URI = ` + +

Styled Node

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); }); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_05.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_05.js index f8eaea289c67..a8b87d3bb9de 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_05.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_05.js @@ -7,23 +7,23 @@ // Tests that the rule view search filter works properly in the computed list // for parsed property name. -const SEARCH = "margin-top:" +const SEARCH = "margin-top:"; -let TEST_URI = [ - '', - '

Styled Node

' -].join("\n"); +const TEST_URI = ` + +

Styled Node

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); }); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_06.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_06.js index 40ece407e3df..dc2fa98b84f7 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_06.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_06.js @@ -7,23 +7,23 @@ // Tests that the rule view search filter works properly in the computed list // when modifying the existing search filter value -const SEARCH = "margin-" +const SEARCH = "margin-"; -let TEST_URI = [ - '', - '

Styled Node

' -].join("\n"); +const TEST_URI = ` + +

Styled Node

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); yield testRemoveTextInFilter(inspector, view); @@ -70,7 +70,6 @@ function* testRemoveTextInFilter(inspector, ruleView) { let win = ruleView.styleWindow; let searchField = ruleView.searchField; - let onRuleViewFiltered = inspector.once("ruleview-filtered"); searchField.focus(); EventUtils.synthesizeKey("VK_BACK_SPACE", {}, win); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_07.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_07.js index 6eb9de1ba7f6..fb555578415d 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_07.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_07.js @@ -7,20 +7,20 @@ // Tests that the rule view search filter works properly in the computed list // for color values. -const SEARCH = "background-color: #F3F3F3" +const SEARCH = "background-color: #F3F3F3"; -let TEST_URI = [ - '', - '
Styled Node' -].join("\n"); +const TEST_URI = ` + +
Styled Node +`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode(".testclass", inspector); yield testAddTextInFilter(inspector, view); }); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_08.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_08.js index 3181a945e16a..5f0360f9b9e5 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_08.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_08.js @@ -9,15 +9,15 @@ const SEARCH = "0px"; -let TEST_URI = [ - "", - "

Styled Node

" -].join("\n"); +const TEST_URI = ` + +

Styled Node

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); @@ -45,7 +45,8 @@ function* testModifyPropertyValueFilter(inspector, view) { is(rule.selectorText, "#testid", "Second rule is #testid."); ok(!propEditor.container.classList.contains("ruleview-highlight"), "margin text property is not highlighted."); - ok(rule.textProps[1].editor.container.classList.contains("ruleview-highlight"), + ok(rule.textProps[1].editor.container.classList + .contains("ruleview-highlight"), "top text property is correctly highlighted."); let onBlur = once(editor.input, "blur"); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_clear.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_clear.js index d7e91080bd55..23c11d65fc44 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_clear.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_clear.js @@ -7,23 +7,23 @@ // Tests that the rule view search filter clear button works properly and clears // the highlighted rules in the computed list. -const SEARCH = "0px" +const SEARCH = "0px"; -let TEST_URI = [ - '', - '

Styled Node

' -].join("\n"); +const TEST_URI = ` + +

Styled Node

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); yield testClearSearchFilter(inspector, view); @@ -71,7 +71,8 @@ function* testClearSearchFilter(inspector, ruleView) { let searchClearButton = ruleView.searchClearButton; let onRuleViewFiltered = inspector.once("ruleview-filtered"); - EventUtils.synthesizeMouseAtCenter(searchClearButton, {}, ruleView.styleWindow); + EventUtils.synthesizeMouseAtCenter(searchClearButton, {}, + ruleView.styleWindow); yield onRuleViewFiltered; diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_expander.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_expander.js index a09472c83dca..650bb56396e4 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_expander.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter-computed-list_expander.js @@ -7,23 +7,23 @@ // Tests that the expanded computed list for a property remains open after // clearing the rule view search filter. -const SEARCH = "0px" +const SEARCH = "0px"; -let TEST_URI = [ - '', - '

Styled Node

' -].join("\n"); +const TEST_URI = ` + +

Styled Node

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testOpenExpanderAndAddTextInFilter(inspector, view); yield testClearSearchFilter(inspector, view); @@ -36,7 +36,7 @@ function* testOpenExpanderAndAddTextInFilter(inspector, ruleView) { let ruleEditor = rule.textProps[0].editor; let computed = ruleEditor.computed; - info("Opening the computed list of margin property") + info("Opening the computed list of margin property"); ruleEditor.expander.click(); info("Setting filter text to \"" + SEARCH + "\""); @@ -75,7 +75,8 @@ function* testClearSearchFilter(inspector, ruleView) { let searchClearButton = ruleView.searchClearButton; let onRuleViewFiltered = inspector.once("ruleview-filtered"); - EventUtils.synthesizeMouseAtCenter(searchClearButton, {}, ruleView.styleWindow); + EventUtils.synthesizeMouseAtCenter(searchClearButton, {}, + ruleView.styleWindow); yield onRuleViewFiltered; diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_01.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_01.js index ec40f58eb557..056270a41abc 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_01.js @@ -8,21 +8,21 @@ const SEARCH = "00F"; -let TEST_URI = [ - '', - '

Styled Node

' -].join("\n"); +const TEST_URI = ` + +

Styled Node

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); }); @@ -46,6 +46,7 @@ function* testAddTextInFilter(inspector, ruleView) { let rule = getRuleViewRuleEditor(ruleView, 1).rule; is(rule.selectorText, "#testid", "Second rule is #testid."); - ok(rule.textProps[0].editor.container.classList.contains("ruleview-highlight"), + ok(rule.textProps[0].editor.container.classList + .contains("ruleview-highlight"), "background-color text property is correctly highlighted."); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_02.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_02.js index bb6b416f0192..824cf4eb1581 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_02.js @@ -8,22 +8,22 @@ const SEARCH = "color"; -let TEST_URI = [ - '', - '
Styled Node
' -].join("\n"); +const TEST_URI = ` + +

Styled Node

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); }); @@ -47,6 +47,7 @@ function* testAddTextInFilter(inspector, ruleView) { let rule = getRuleViewRuleEditor(ruleView, 1).rule; is(rule.selectorText, "#testid", "Second rule is #testid."); - ok(rule.textProps[1].editor.container.classList.contains("ruleview-highlight"), + ok(rule.textProps[1].editor.container.classList + .contains("ruleview-highlight"), "background-color text property is correctly highlighted."); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_03.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_03.js index 5af1fdb2e400..aee783c8ed86 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_03.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_03.js @@ -8,21 +8,21 @@ const SEARCH = "#test"; -let TEST_URI = [ - '', - '
Styled Node
' -].join("\n"); +const TEST_URI = ` + +

Styled Node

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); }); @@ -46,6 +46,6 @@ function* testAddTextInFilter(inspector, ruleView) { let ruleEditor = getRuleViewRuleEditor(ruleView, 1); is(ruleEditor.rule.selectorText, "#testid", "Second rule is #testid."); - ok(ruleEditor.selectorText.children[0].classList.contains("ruleview-highlight"), - "#testid selector is highlighted.") + ok(ruleEditor.selectorText.children[0].classList + .contains("ruleview-highlight"), "#testid selector is highlighted."); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_04.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_04.js index f667d61b3807..d2f322e65f90 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_04.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_04.js @@ -4,14 +4,15 @@ "use strict"; -// Tests that the rule view search filter works properly for keyframe rule selectors. +// Tests that the rule view search filter works properly for keyframe rule +// selectors. -const SEARCH = "20%" +const SEARCH = "20%"; const TEST_URI = TEST_URL_ROOT + "doc_keyframeanimation.html"; add_task(function*() { yield addTab(TEST_URI); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#boxy", inspector); yield testAddTextInFilter(inspector, view); }); @@ -35,5 +36,5 @@ function* testAddTextInFilter(inspector, ruleView) { is(ruleEditor.rule.domRule.keyText, "20%", "Second rule is 20%."); ok(ruleEditor.selectorText.classList.contains("ruleview-highlight"), - "20% selector is highlighted.") + "20% selector is highlighted."); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_05.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_05.js index 273ddcff1027..138a3c3d8721 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_05.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_05.js @@ -4,25 +4,26 @@ "use strict"; -// Tests that the rule view search filter works properly for multiple rule selectors. +// Tests that the rule view search filter works properly for multiple rule +// selectors. const SEARCH = "body"; -let TEST_URI = [ - '', - '
Styled Node
' -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); }); @@ -47,6 +48,6 @@ function* testAddTextInFilter(inspector, ruleView) { is(ruleEditor.rule.selectorText, "html, body, div", "Second rule is html, body, div."); - ok(ruleEditor.selectorText.children[2].classList.contains("ruleview-highlight"), - "body selector is highlighted.") + ok(ruleEditor.selectorText.children[2].classList + .contains("ruleview-highlight"), "body selector is highlighted."); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_06.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_06.js index f29257d0b70b..bd6a8d63578d 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_06.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_06.js @@ -4,25 +4,26 @@ "use strict"; -// Tests that the rule view search filter works properly for property line input. +// Tests that the rule view search filter works properly for property line +// input. const SEARCH = "background-color:#00F"; -let TEST_URI = [ - '', - '
Styled Node
' -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); }); @@ -46,6 +47,7 @@ function* testAddTextInFilter(inspector, ruleView) { let rule = getRuleViewRuleEditor(ruleView, 1).rule; is(rule.selectorText, ".testclass", "Second rule is .testclass."); - ok(rule.textProps[0].editor.container.classList.contains("ruleview-highlight"), + ok(rule.textProps[0].editor.container.classList + .contains("ruleview-highlight"), "background-color text property is correctly highlighted."); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_07.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_07.js index 7ec425eaf491..fb806ffdb956 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_07.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_07.js @@ -4,25 +4,26 @@ "use strict"; -// Tests that the rule view search filter works properly for parsed property value. +// Tests that the rule view search filter works properly for parsed property +// value. const SEARCH = ":00F"; -let TEST_URI = [ - '', - '
Styled Node
' -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); }); @@ -46,6 +47,7 @@ function* testAddTextInFilter(inspector, ruleView) { let rule = getRuleViewRuleEditor(ruleView, 1).rule; is(rule.selectorText, "#testid", "Second rule is #testid."); - ok(rule.textProps[0].editor.container.classList.contains("ruleview-highlight"), + ok(rule.textProps[0].editor.container.classList + .contains("ruleview-highlight"), "background-color text property is correctly highlighted."); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_08.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_08.js index 12db8b24f9fc..62f234931259 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_08.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_08.js @@ -4,25 +4,26 @@ "use strict"; -// Tests that the rule view search filter works properly for parsed property name. +// Tests that the rule view search filter works properly for parsed property +// name. const SEARCH = "background:"; -let TEST_URI = [ - '', - '
Styled Node
' -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); }); @@ -46,6 +47,7 @@ function* testAddTextInFilter(inspector, ruleView) { let rule = getRuleViewRuleEditor(ruleView, 1).rule; is(rule.selectorText, "#testid", "Second rule is #testid."); - ok(rule.textProps[0].editor.container.classList.contains("ruleview-highlight"), + ok(rule.textProps[0].editor.container.classList + .contains("ruleview-highlight"), "background-color text property is correctly highlighted."); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_09.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_09.js index 4cc5a5c91641..6cb6d436495b 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_09.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_09.js @@ -8,18 +8,18 @@ const SEARCH = "color"; -let TEST_URI = [ - '', - '
Styled Node
' -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); }); @@ -41,6 +41,7 @@ function* testAddTextInFilter(inspector, ruleView) { let rule = getRuleViewRuleEditor(ruleView, 0).rule; is(rule.selectorText, "element", "First rule is inline element."); - ok(rule.textProps[0].editor.container.classList.contains("ruleview-highlight"), + ok(rule.textProps[0].editor.container.classList + .contains("ruleview-highlight"), "background-color text property is correctly highlighted."); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_10.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_10.js index 647f88f8f90d..51e92b0b455f 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_10.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_10.js @@ -7,23 +7,23 @@ // Tests that the rule view search filter works properly when modifying the // existing search filter value -const SEARCH = "00F" +const SEARCH = "00F"; -let TEST_URI = [ - '', - '
Styled Node
' -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); yield testRemoveTextInFilter(inspector, view); @@ -48,7 +48,8 @@ function* testAddTextInFilter(inspector, ruleView) { let rule = getRuleViewRuleEditor(ruleView, 1).rule; is(rule.selectorText, "#testid", "Second rule is #testid."); - ok(rule.textProps[0].editor.container.classList.contains("ruleview-highlight"), + ok(rule.textProps[0].editor.container.classList + .contains("ruleview-highlight"), "background-color text property is correctly highlighted."); } @@ -57,7 +58,6 @@ function* testRemoveTextInFilter(inspector, ruleView) { let win = ruleView.styleWindow; let searchField = ruleView.searchField; - let onRuleViewFiltered = inspector.once("ruleview-filtered"); searchField.focus(); EventUtils.synthesizeKey("VK_BACK_SPACE", {}, win); @@ -71,12 +71,14 @@ function* testRemoveTextInFilter(inspector, ruleView) { let rule = getRuleViewRuleEditor(ruleView, 1).rule; is(rule.selectorText, "#testid", "Second rule is #testid."); - ok(rule.textProps[0].editor.container.classList.contains("ruleview-highlight"), + ok(rule.textProps[0].editor.container.classList + .contains("ruleview-highlight"), "background-color text property is correctly highlighted."); rule = getRuleViewRuleEditor(ruleView, 2).rule; is(rule.selectorText, ".testclass", "Second rule is .testclass."); - ok(rule.textProps[0].editor.container.classList.contains("ruleview-highlight"), + ok(rule.textProps[0].editor.container.classList + .contains("ruleview-highlight"), "width text property is correctly highlighted."); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_11.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_11.js index 6ce6adbd5fab..68cef34f239a 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_11.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_11.js @@ -8,21 +8,21 @@ const SEARCH = "!important"; -let TEST_URI = [ - '', - '

Styled Node

' -].join("\n"); +const TEST_URI = ` + +

Styled Node

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); }); @@ -46,6 +46,7 @@ function* testAddTextInFilter(inspector, ruleView) { let rule = getRuleViewRuleEditor(ruleView, 1).rule; is(rule.selectorText, "#testid", "Second rule is #testid."); - ok(rule.textProps[0].editor.container.classList.contains("ruleview-highlight"), + ok(rule.textProps[0].editor.container.classList + .contains("ruleview-highlight"), "background-color text property is correctly highlighted."); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_12.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_12.js index cd3c9c23c72b..3fe1e124ba1e 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_12.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_12.js @@ -11,7 +11,7 @@ const TEST_URI = TEST_URL_ROOT + "doc_urls_clickable.html"; add_task(function*() { yield addTab(TEST_URI); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode(".relative1", inspector); yield testAddTextInFilter(inspector, view); }); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_13.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_13.js index 8697006e4f74..332d924becc8 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_13.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_13.js @@ -12,7 +12,7 @@ const TEST_URI = TEST_URL_ROOT + "doc_urls_clickable.html"; add_task(function*() { yield addTab(TEST_URI); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode(".relative1", inspector); yield testAddTextInFilter(inspector, view); }); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_14.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_14.js index 4298bbc686bc..8b5327b40954 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_14.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_14.js @@ -9,15 +9,15 @@ const SEARCH = "100%"; -let TEST_URI = [ - "", - "

Styled Node

" -].join("\n"); +const TEST_URI = ` + +

Styled Node

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); @@ -44,7 +44,8 @@ function* testModifyPropertyValueFilter(inspector, view) { info("Check that the correct rules are visible"); is(view.element.children.length, 2, "Should have 2 rules."); is(rule.selectorText, "#testid", "Second rule is #testid."); - ok(rule.textProps[0].editor.container.classList.contains("ruleview-highlight"), + ok(rule.textProps[0].editor.container.classList + .contains("ruleview-highlight"), "width text property is correctly highlighted."); ok(!propEditor.container.classList.contains("ruleview-highlight"), "height text property is not highlighted."); @@ -59,4 +60,3 @@ function* testModifyPropertyValueFilter(inspector, view) { ok(propEditor.container.classList.contains("ruleview-highlight"), "height text property is correctly highlighted."); } - diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_15.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_15.js index 16c8e1bb986a..0b43a0f8670e 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_15.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_15.js @@ -9,15 +9,15 @@ const SEARCH = "e"; -let TEST_URI = [ - "", - "

Styled Node

" -].join("\n"); +const TEST_URI = ` + +

Styled Node

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); @@ -46,7 +46,8 @@ function* testModifyPropertyNameFilter(inspector, view) { is(rule.selectorText, "#testid", "Second rule is #testid."); ok(!propEditor.container.classList.contains("ruleview-highlight"), "width text property is not highlighted."); - ok(rule.textProps[1].editor.container.classList.contains("ruleview-highlight"), + ok(rule.textProps[1].editor.container.classList + .contains("ruleview-highlight"), "height text property is correctly highlighted."); let onBlur = once(editor.input, "blur"); @@ -59,4 +60,3 @@ function* testModifyPropertyNameFilter(inspector, view) { ok(propEditor.container.classList.contains("ruleview-highlight"), "margin-left text property is correctly highlighted."); } - diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_16.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_16.js index 035a1d790dee..d7a535777f98 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_16.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_16.js @@ -9,15 +9,15 @@ const SEARCH = "100%"; -let TEST_URI = [ - "", - "

Styled Node

" -].join("\n"); +const TEST_URI = ` + +

Styled Node

+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); @@ -43,9 +43,11 @@ function* testNewPropertyFilter(inspector, view) { info("Check that the correct rules are visible"); is(view.element.children.length, 2, "Should have 2 rules."); is(rule.selectorText, "#testid", "Second rule is #testid."); - ok(rule.textProps[0].editor.container.classList.contains("ruleview-highlight"), + ok(rule.textProps[0].editor.container.classList + .contains("ruleview-highlight"), "width text property is correctly highlighted."); - ok(!rule.textProps[1].editor.container.classList.contains("ruleview-highlight"), + ok(!rule.textProps[1].editor.container.classList + .contains("ruleview-highlight"), "height text property is not highlighted."); info("Test creating a new property"); @@ -75,4 +77,3 @@ function* testNewPropertyFilter(inspector, view) { ok(propEditor.container.classList.contains("ruleview-highlight"), "margin-left text property is correctly highlighted."); } - diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_clear.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_clear.js index 8afb84730bbc..8ffd1b55a16c 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_clear.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_clear.js @@ -8,21 +8,21 @@ const SEARCH = "00F"; -let TEST_URI = [ - '', - '
Styled Node
' -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); yield testClearSearchFilter(inspector, view); @@ -47,7 +47,8 @@ function* testAddTextInFilter(inspector, ruleView) { let rule = getRuleViewRuleEditor(ruleView, 1).rule; is(rule.selectorText, "#testid", "Second rule is #testid."); - ok(rule.textProps[0].editor.container.classList.contains("ruleview-highlight"), + ok(rule.textProps[0].editor.container.classList + .contains("ruleview-highlight"), "background-color text property is correctly highlighted."); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_context-menu.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_context-menu.js index 04652d1ee8dc..6d1f1d485a22 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_context-menu.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_context-menu.js @@ -7,14 +7,11 @@ // Test rule view search filter context menu works properly. const TEST_INPUT = "h1"; +const TEST_URI = "

test filter context menu

"; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,

test filter context menu

"); - - info("Opening the rule-view"); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {toolbox, inspector, view} = yield openRuleView(); - - info("Selecting the test node"); yield selectNode("h1", inspector); let win = view.styleWindow; diff --git a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_escape-keypress.js b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_escape-keypress.js index 7652a5a36b4f..c0c1f3375e33 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_search-filter_escape-keypress.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_search-filter_escape-keypress.js @@ -7,21 +7,21 @@ // Tests that the rule view search filter escape keypress will clear the search // field. -let TEST_URI = [ - '', - '
Styled Node
' -].join("\n"); +const TEST_URI = ` + +
Styled Node
+`; add_task(function*() { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); yield testAddTextInFilter(inspector, view); yield testEscapeKeypress(inspector, view); @@ -46,7 +46,8 @@ function* testAddTextInFilter(inspector, ruleView) { let rule = getRuleViewRuleEditor(ruleView, 1).rule; is(rule.selectorText, "#testid", "Second rule is #testid."); - ok(rule.textProps[0].editor.container.classList.contains("ruleview-highlight"), + ok(rule.textProps[0].editor.container.classList + .contains("ruleview-highlight"), "background-color text property is correctly highlighted."); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_select-and-copy-styles.js b/browser/devtools/styleinspector/test/browser_ruleview_select-and-copy-styles.js index a24c51936bf6..075f88f0ef98 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_select-and-copy-styles.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_select-and-copy-styles.js @@ -10,34 +10,38 @@ XPCOMUtils.defineLazyGetter(this, "osString", function() { return Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS; }); +const TEST_URI = ` + +
+

Some header text

+

hi.

+

I am a test-case. This text exists + solely to provide some things to + highlight and count + style list-items in the box at right. If you are reading this, + you should go do something else instead. Maybe read a book. Or better + yet, write some test-cases for another bit of code. + some text

+

more text

+

even more text

+
+`; + add_task(function*() { - yield addTab("data:text/html;charset=utf-8,

rule view context menu test

"); - - info("Creating the test document"); - content.document.body.innerHTML = '
\n' + - '

Some header text

\n' + - '

hi.

\n' + - '

I am a test-case. This text exists ' + - 'solely to provide some things to ' + - 'highlight and count ' + - 'style list-items in the box at right. If you are reading this, ' + - 'you should go do something else instead. Maybe read a book. Or better ' + - 'yet, write some test-cases for another bit of code. ' + - 'some text

\n' + - '

more text

\n' + - '

even more text

' + - '
'; - content.document.title = "Rule view context menu test"; - + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); - - info("Selecting the test node"); yield selectNode("div", inspector); - yield checkCopySelection(view); yield checkSelectAll(view); }); @@ -70,7 +74,8 @@ function* checkCopySelection(view) { {button: 2, type: "contextmenu"}, win); yield onPopup; - ok(!view._contextmenu.menuitemCopy.hidden, "Copy menu item is not hidden as expected"); + ok(!view._contextmenu.menuitemCopy.hidden, + "Copy menu item is not hidden as expected"); try { yield waitForClipboard(() => view._contextmenu.menuitemCopy.click(), @@ -89,7 +94,8 @@ function* checkSelectAll(view) { let win = view.styleWindow; let prop = contentDoc.querySelector(".ruleview-property"); - info("Checking that _SelectAll() then copy returns the correct clipboard value"); + info("Checking that _SelectAll() then copy returns the correct " + + "clipboard value"); view._contextmenu._onSelectAll(); let expectedPattern = "[\\r\\n]+" + "element {[\\r\\n]+" + @@ -107,7 +113,8 @@ function* checkSelectAll(view) { {button: 2, type: "contextmenu"}, win); yield onPopup; - ok(!view._contextmenu.menuitemCopy.hidden, "Copy menu item is not hidden as expected"); + ok(!view._contextmenu.menuitemCopy.hidden, + "Copy menu item is not hidden as expected"); try { yield waitForClipboard(() => view._contextmenu.menuitemCopy.click(), diff --git a/browser/devtools/styleinspector/test/browser_ruleview_selector-highlighter_01.js b/browser/devtools/styleinspector/test/browser_ruleview_selector-highlighter_01.js index 883558cae0b0..872d7755a500 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_selector-highlighter_01.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_selector-highlighter_01.js @@ -7,20 +7,21 @@ // Test that the selector highlighter is created when clicking on a selector // icon in the rule view. -const PAGE_CONTENT = [ - '', - 'Test the selector highlighter' -].join("\n"); +const TEST_URI = ` + + Test the selector highlighter +`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8," + PAGE_CONTENT); - + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {view} = yield openRuleView(); - ok(!view.selectorHighlighter, "No selectorhighlighter exist in the rule-view"); + + ok(!view.selectorHighlighter, + "No selectorhighlighter exist in the rule-view"); info("Clicking on a selector icon"); let icon = getRuleViewSelectorHighlighterIcon(view, "body, p, td"); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_selector-highlighter_02.js b/browser/devtools/styleinspector/test/browser_ruleview_selector-highlighter_02.js index 805fdbecdb5b..fba9e48f50af 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_selector-highlighter_02.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_selector-highlighter_02.js @@ -10,21 +10,20 @@ // Note that in this test, we mock the highlighter front, merely testing the // behavior of the style-inspector UI for now -const PAGE_CONTENT = [ - '', - '

Testing the selector highlighter

' -].join("\n"); +const TEST_URI = ` + +

Testing the selector highlighter

+`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8," + PAGE_CONTENT); - + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); // Mock the highlighter front to get the reference of the NodeFront diff --git a/browser/devtools/styleinspector/test/browser_ruleview_selector-highlighter_03.js b/browser/devtools/styleinspector/test/browser_ruleview_selector-highlighter_03.js index 6de0ff286806..d8454a5e7734 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_selector-highlighter_03.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_selector-highlighter_03.js @@ -9,19 +9,18 @@ // Note that in this test, we mock the highlighter front, merely testing the // behavior of the style-inspector UI for now -const PAGE_CONTENT = [ - '', - '
Node 1
', - '
Node 2
' -].join("\n"); +const TEST_URI = ` + +
Node 1
+
Node 2
+`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8," + PAGE_CONTENT); - + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); // Mock the highlighter front. @@ -61,7 +60,8 @@ add_task(function*() { info("Selecting .node-2"); yield selectNode(".node-2", inspector); - ok(HighlighterFront.isShown, "The highlighter is still shown after selection"); + ok(HighlighterFront.isShown, + "The highlighter is still shown after selection"); info("With .node-2 selected, click on the div selector icon"); icon = getRuleViewSelectorHighlighterIcon(view, "div"); diff --git a/browser/devtools/styleinspector/test/browser_ruleview_style-editor-link.js b/browser/devtools/styleinspector/test/browser_ruleview_style-editor-link.js index 5cbc5d73bc08..9760415841df 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_style-editor-link.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_style-editor-link.js @@ -57,17 +57,15 @@ const DOCUMENT_URL = "data:text/html;charset=utf-8,"+encodeURIComponent( add_task(function*() { yield addTab(DOCUMENT_URL); let {toolbox, inspector, view} = yield openRuleView(); - - info("Select the test node"); yield selectNode("div", inspector); - yield testInlineStyle(view, inspector); + yield testInlineStyle(view); yield testFirstInlineStyleSheet(view, toolbox); yield testSecondInlineStyleSheet(view, toolbox); yield testExternalStyleSheet(view, toolbox); }); -function* testInlineStyle(view, inspector) { +function* testInlineStyle(view) { info("Testing inline style"); let onTab = waitForTab(); @@ -112,7 +110,8 @@ function* testSecondInlineStyleSheet(view, toolbox) { clickLinkByIndex(view, 3); let editor = yield onSelected; - is(toolbox.currentToolId, "styleeditor", "The style editor is selected again"); + is(toolbox.currentToolId, "styleeditor", + "The style editor is selected again"); validateStyleEditorSheet(editor, 1); } @@ -131,7 +130,8 @@ function* testExternalStyleSheet(view, toolbox) { clickLinkByIndex(view, 1); let editor = yield onSelected; - is(toolbox.currentToolId, "styleeditor", "The style editor is selected again"); + is(toolbox.currentToolId, "styleeditor", + "The style editor is selected again"); validateStyleEditorSheet(editor, 2); } @@ -141,7 +141,8 @@ function validateStyleEditorSheet(editor, expectedSheetIndex) { "loaded stylesheet index matches document stylesheet"); let sheet = content.document.styleSheets[expectedSheetIndex]; - is(editor.styleSheet.href, sheet.href, "loaded stylesheet href matches document stylesheet"); + is(editor.styleSheet.href, sheet.href, + "loaded stylesheet href matches document stylesheet"); } function testRuleViewLinkLabel(view) { diff --git a/browser/devtools/styleinspector/test/browser_ruleview_urls-clickable.js b/browser/devtools/styleinspector/test/browser_ruleview_urls-clickable.js index 4d753e2edb1d..6a60e59ba0f0 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_urls-clickable.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_urls-clickable.js @@ -8,11 +8,13 @@ const TEST_URI = TEST_URL_ROOT + "doc_urls_clickable.html"; const TEST_IMAGE = TEST_URL_ROOT + "doc_test_image.png"; -const BASE_64_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; +const BASE_64_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAA" + + "FCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAA" + + "BJRU5ErkJggg=="; add_task(function*() { yield addTab(TEST_URI); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector, view} = yield openRuleView(); yield selectNodes(inspector, view); }); @@ -26,36 +28,43 @@ function* selectNodes(inspector, ruleView) { let inlineresolved = ".inline-resolved"; yield selectNode(relative1, inspector); - let relativeLink = ruleView.styleDocument.querySelector(".ruleview-propertyvaluecontainer a"); + let relativeLink = ruleView.styleDocument + .querySelector(".ruleview-propertyvaluecontainer a"); ok(relativeLink, "Link exists for relative1 node"); is(relativeLink.getAttribute("href"), TEST_IMAGE, "href matches"); yield selectNode(relative2, inspector); - relativeLink = ruleView.styleDocument.querySelector(".ruleview-propertyvaluecontainer a"); + relativeLink = ruleView.styleDocument + .querySelector(".ruleview-propertyvaluecontainer a"); ok(relativeLink, "Link exists for relative2 node"); is(relativeLink.getAttribute("href"), TEST_IMAGE, "href matches"); yield selectNode(absolute, inspector); - let absoluteLink = ruleView.styleDocument.querySelector(".ruleview-propertyvaluecontainer a"); + let absoluteLink = ruleView.styleDocument + .querySelector(".ruleview-propertyvaluecontainer a"); ok(absoluteLink, "Link exists for absolute node"); is(absoluteLink.getAttribute("href"), TEST_IMAGE, "href matches"); yield selectNode(inline, inspector); - let inlineLink = ruleView.styleDocument.querySelector(".ruleview-propertyvaluecontainer a"); + let inlineLink = ruleView.styleDocument + .querySelector(".ruleview-propertyvaluecontainer a"); ok(inlineLink, "Link exists for inline node"); is(inlineLink.getAttribute("href"), TEST_IMAGE, "href matches"); yield selectNode(base64, inspector); - let base64Link = ruleView.styleDocument.querySelector(".ruleview-propertyvaluecontainer a"); + let base64Link = ruleView.styleDocument + .querySelector(".ruleview-propertyvaluecontainer a"); ok(base64Link, "Link exists for base64 node"); is(base64Link.getAttribute("href"), BASE_64_URL, "href matches"); yield selectNode(inlineresolved, inspector); - let inlineResolvedLink = ruleView.styleDocument.querySelector(".ruleview-propertyvaluecontainer a"); + let inlineResolvedLink = ruleView.styleDocument + .querySelector(".ruleview-propertyvaluecontainer a"); ok(inlineResolvedLink, "Link exists for style tag node"); is(inlineResolvedLink.getAttribute("href"), TEST_IMAGE, "href matches"); yield selectNode(noimage, inspector); - let noimageLink = ruleView.styleDocument.querySelector(".ruleview-propertyvaluecontainer a"); + let noimageLink = ruleView.styleDocument + .querySelector(".ruleview-propertyvaluecontainer a"); ok(!noimageLink, "There is no link for the node with no background image"); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_user-agent-styles-uneditable.js b/browser/devtools/styleinspector/test/browser_ruleview_user-agent-styles-uneditable.js index f898bf6079cd..a6edd13bd9be 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_user-agent-styles-uneditable.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_user-agent-styles-uneditable.js @@ -7,21 +7,22 @@ // Check that user agent styles are never editable via // the UI +const TEST_URI = ` +
+
+     inspect user agent styles
+   
+
+`; + let PREF_UA_STYLES = "devtools.inspector.showUserAgentStyles"; -const TEST_URI = "data:text/html;charset=utf-8," + - "
" + - "
" +
-  "   inspect user agent styles" +
-  " 
" + - "
"; add_task(function*() { - info ("Starting the test with the pref set to true before toolbox is opened"); + info("Starting the test with the pref set to true before toolbox is opened"); Services.prefs.setBoolPref(PREF_UA_STYLES, true); - info ("Opening the testcase and toolbox") - yield addTab(TEST_URI); - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield userAgentStylesUneditable(inspector, view); @@ -30,21 +31,26 @@ add_task(function*() { }); function* userAgentStylesUneditable(inspector, view) { - info ("Making sure that UI is not editable for user agent styles"); + info("Making sure that UI is not editable for user agent styles"); yield selectNode("a", inspector); let uaRules = view._elementStyle.rules.filter(rule=>!rule.editor.isEditable); for (let rule of uaRules) { - ok (rule.editor.element.hasAttribute("uneditable"), "UA rules have uneditable attribute"); + ok(rule.editor.element.hasAttribute("uneditable"), + "UA rules have uneditable attribute"); - ok (!rule.textProps[0].editor.nameSpan._editable, "nameSpan is not editable"); - ok (!rule.textProps[0].editor.valueSpan._editable, "valueSpan is not editable"); - ok (!rule.editor.closeBrace._editable, "closeBrace is not editable"); + ok(!rule.textProps[0].editor.nameSpan._editable, + "nameSpan is not editable"); + ok(!rule.textProps[0].editor.valueSpan._editable, + "valueSpan is not editable"); + ok(!rule.editor.closeBrace._editable, "closeBrace is not editable"); - let colorswatch = rule.editor.element.querySelector(".ruleview-colorswatch"); + let colorswatch = rule.editor.element + .querySelector(".ruleview-colorswatch"); if (colorswatch) { - ok (!view.tooltips.colorPicker.swatches.has(colorswatch), "The swatch is not editable"); + ok(!view.tooltips.colorPicker.swatches.has(colorswatch), + "The swatch is not editable"); } } } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_user-agent-styles.js b/browser/devtools/styleinspector/test/browser_ruleview_user-agent-styles.js index 7541b4fd29f4..cda1f369e180 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_user-agent-styles.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_user-agent-styles.js @@ -10,29 +10,23 @@ let PREF_UA_STYLES = "devtools.inspector.showUserAgentStyles"; const { PrefObserver } = require("devtools/styleeditor/utils"); -const TEST_DOC = ' \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
\ -
                         \
-                          inspect user agent styles \
-                        
\ -
\ - \ - '; - -const TEST_URI = "data:text/html;charset=utf-8," + encodeURIComponent(TEST_DOC); +const TEST_URI = ` + + + + + + +
+
+      inspect user agent styles
+    
+
+`; const TEST_DATA = [ { @@ -78,21 +72,20 @@ const TEST_DATA = [ ]; add_task(function*() { - info ("Starting the test with the pref set to true before toolbox is opened"); + info("Starting the test with the pref set to true before toolbox is opened"); yield setUserAgentStylesPref(true); - info ("Opening the testcase and toolbox") - yield addTab(TEST_URI); - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); - info ("Making sure that UA styles are visible on initial load") + info("Making sure that UA styles are visible on initial load"); yield userAgentStylesVisible(inspector, view); - info ("Making sure that setting the pref to false hides UA styles"); + info("Making sure that setting the pref to false hides UA styles"); yield setUserAgentStylesPref(false); yield userAgentStylesNotVisible(inspector, view); - info ("Making sure that resetting the pref to true shows UA styles again"); + info("Making sure that resetting the pref to true shows UA styles again"); yield setUserAgentStylesPref(true); yield userAgentStylesVisible(inspector, view); @@ -114,7 +107,7 @@ function* setUserAgentStylesPref(val) { } function* userAgentStylesVisible(inspector, view) { - info ("Making sure that user agent styles are currently visible"); + info("Making sure that user agent styles are currently visible"); let userRules; let uaRules; @@ -125,23 +118,23 @@ function* userAgentStylesVisible(inspector, view) { userRules = view._elementStyle.rules.filter(rule=>rule.editor.isEditable); uaRules = view._elementStyle.rules.filter(rule=>!rule.editor.isEditable); - is (userRules.length, data.numUserRules, "Correct number of user rules"); - ok (uaRules.length > data.numUARules, "Has UA rules"); + is(userRules.length, data.numUserRules, "Correct number of user rules"); + ok(uaRules.length > data.numUARules, "Has UA rules"); } - ok (userRules.some(rule=> rule.matchedSelectors.length === 1), + ok(userRules.some(rule=> rule.matchedSelectors.length === 1), "There is an inline style for element in user styles"); - ok (uaRules.some(rule=> rule.matchedSelectors.indexOf(":-moz-any-link")), + ok(uaRules.some(rule=> rule.matchedSelectors.indexOf(":-moz-any-link")), "There is a rule for :-moz-any-link"); - ok (uaRules.some(rule=> rule.matchedSelectors.indexOf("*|*:link")), + ok(uaRules.some(rule=> rule.matchedSelectors.indexOf("*|*:link")), "There is a rule for *|*:link"); - ok (uaRules.some(rule=> rule.matchedSelectors.length === 1), + ok(uaRules.some(rule=> rule.matchedSelectors.length === 1), "Inline styles for ua styles"); } function* userAgentStylesNotVisible(inspector, view) { - info ("Making sure that user agent styles are not currently visible"); + info("Making sure that user agent styles are not currently visible"); let userRules; let uaRules; @@ -152,22 +145,24 @@ function* userAgentStylesNotVisible(inspector, view) { userRules = view._elementStyle.rules.filter(rule=>rule.editor.isEditable); uaRules = view._elementStyle.rules.filter(rule=>!rule.editor.isEditable); - is (userRules.length, data.numUserRules, "Correct number of user rules"); - is (uaRules.length, data.numUARules, "No UA rules"); + is(userRules.length, data.numUserRules, "Correct number of user rules"); + is(uaRules.length, data.numUARules, "No UA rules"); } } function* compareAppliedStylesWithUI(inspector, view, filter) { - info ("Making sure that UI is consistent with pageStyle.getApplied"); + info("Making sure that UI is consistent with pageStyle.getApplied"); - let entries = yield inspector.pageStyle.getApplied(inspector.selection.nodeFront, { + let entries = yield inspector.pageStyle.getApplied( + inspector.selection.nodeFront, { inherited: true, matchedSelectors: true, filter: filter }); let elementStyle = view._elementStyle; - is(elementStyle.rules.length, entries.length, "Should have correct number of rules (" + entries.length + ")"); + is(elementStyle.rules.length, entries.length, + "Should have correct number of rules (" + entries.length + ")"); entries = entries.sort((a, b) => { return (a.pseudoElement || "z") > (b.pseudoElement || "z"); @@ -175,8 +170,11 @@ function* compareAppliedStylesWithUI(inspector, view, filter) { entries.forEach((entry, i) => { let elementStyleRule = elementStyle.rules[i]; - is (elementStyleRule.inherited, entry.inherited, "Same inherited (" +entry.inherited+ ")" ); - is (elementStyleRule.isSystem, entry.isSystem, "Same isSystem (" +entry.isSystem+ ")"); - is (elementStyleRule.editor.isEditable, !entry.isSystem, "Editor isEditable opposite of UA (" +entry.isSystem+ ")"); + is(elementStyleRule.inherited, entry.inherited, + "Same inherited (" + entry.inherited + ")"); + is(elementStyleRule.isSystem, entry.isSystem, + "Same isSystem (" + entry.isSystem + ")"); + is(elementStyleRule.editor.isEditable, !entry.isSystem, + "Editor isEditable opposite of UA (" + entry.isSystem + ")"); }); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_user-property-reset.js b/browser/devtools/styleinspector/test/browser_ruleview_user-property-reset.js index 0bb5bc670186..23dc2fa57b73 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_user-property-reset.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_user-property-reset.js @@ -7,15 +7,14 @@ // Test that user set style properties can be changed from the markup-view and // don't survive page reload -let TEST_PAGE = [ - "data:text/html;charset=utf-8,", - "

element 1

", - "

element 2

" -].join(""); +const TEST_URI = ` +

element 1

+

element 2

+`; add_task(function*() { - yield addTab(TEST_PAGE); - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("#id1", inspector); yield modifyRuleViewWidth("300px", view, inspector); @@ -40,7 +39,8 @@ function getStyleRule(ruleView) { function* modifyRuleViewWidth(value, ruleView, inspector) { info("Getting the property value element"); - let valueSpan = getStyleRule(ruleView).querySelector(".ruleview-propertyvalue"); + let valueSpan = getStyleRule(ruleView) + .querySelector(".ruleview-propertyvalue"); info("Focusing the property value to set it to edit mode"); let editor = yield focusEditableField(ruleView, valueSpan.parentNode); @@ -49,14 +49,16 @@ function* modifyRuleViewWidth(value, ruleView, inspector) { info("Setting the new value"); editor.input.value = value; - info("Pressing return and waiting for the field to blur and for the markup-view to show the mutation"); + info("Pressing return and waiting for the field to blur and for the " + + "markup-view to show the mutation"); let onBlur = once(editor.input, "blur", true); let onMutation = inspector.once("markupmutation"); EventUtils.sendKey("return"); yield onBlur; yield onMutation; - info("Escaping out of the new property field that has been created after the value was edited"); + info("Escaping out of the new property field that has been created after " + + "the value was edited"); let onNewFieldBlur = once(ruleView.styleDocument.activeElement, "blur", true); EventUtils.sendKey("escape"); yield onNewFieldBlur; @@ -71,14 +73,17 @@ function* getContainerStyleAttrValue(id, {walker, markup}) { if (attrName.textContent === "style") { return container.elt.querySelectorAll(".attr-value")[attrIndex]; } - attrIndex ++; + attrIndex++; } } function* assertRuleAndMarkupViewWidth(id, value, ruleView, inspector) { - let valueSpan = getStyleRule(ruleView).querySelector(".ruleview-propertyvalue"); - is(valueSpan.textContent, value, "Rule-view style width is " + value + " as expected"); + let valueSpan = getStyleRule(ruleView) + .querySelector(".ruleview-propertyvalue"); + is(valueSpan.textContent, value, + "Rule-view style width is " + value + " as expected"); let attr = yield getContainerStyleAttrValue(id, inspector); - is(attr.textContent.replace(/\s/g, ""), "width:" + value + ";", "Markup-view style attribute width is " + value); + is(attr.textContent.replace(/\s/g, ""), + "width:" + value + ";", "Markup-view style attribute width is " + value); } diff --git a/browser/devtools/styleinspector/test/browser_styleinspector_context-menu-copy-color_01.js b/browser/devtools/styleinspector/test/browser_styleinspector_context-menu-copy-color_01.js index f707fa0ad37c..5db4a420deda 100644 --- a/browser/devtools/styleinspector/test/browser_styleinspector_context-menu-copy-color_01.js +++ b/browser/devtools/styleinspector/test/browser_styleinspector_context-menu-copy-color_01.js @@ -5,35 +5,27 @@ // Test "Copy color" item of the context menu #1: Test _isColorPopup. -const TEST_COLOR = "#123ABC"; -const COLOR_SELECTOR = "span[data-color]"; +const TEST_URI = ` +
+ Test "Copy color" context menu option +
+`; + +const TEST_CASES = [ + { + viewName: "RuleView", + initializer: openRuleView + }, + { + viewName: "ComputedView", + initializer: openComputedView + } +]; add_task(function* () { // Test is slow on Linux EC2 instances - Bug 1137765 requestLongerTimeout(2); - - const TEST_DOC = ' \ - \ -
\ - Test "Copy color" context menu option \ -
\ - \ - '; - - const TEST_CASES = [ - { - viewName: "RuleView", - initializer: openRuleView - }, - { - viewName: "ComputedView", - initializer: openComputedView - } - ]; - - yield addTab("data:text/html;charset=utf8," + encodeURIComponent(TEST_DOC)); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); for (let test of TEST_CASES) { yield testView(test); @@ -58,7 +50,7 @@ function* testView({viewName, initializer}) { function testIsColorValueNode(view) { info("Testing that child nodes of color nodes are detected."); let root = rootElement(view); - let colorNode = root.querySelector(COLOR_SELECTOR); + let colorNode = root.querySelector("span[data-color]"); ok(colorNode, "Color node found"); for (let node of iterateNodes(colorNode)) { @@ -93,7 +85,7 @@ function testIsColorPopupOnNode(view, node) { let correct = isColorValueNode(node); is(result, correct, "_isColorPopup returned the expected value " + correct); - is(view._contextmenu._colorToCopy, (correct) ? TEST_COLOR : "", + is(view._contextmenu._colorToCopy, (correct) ? "#123ABC" : "", "_colorToCopy was set to the expected value"); } diff --git a/browser/devtools/styleinspector/test/browser_styleinspector_context-menu-copy-color_02.js b/browser/devtools/styleinspector/test/browser_styleinspector_context-menu-copy-color_02.js index a4645c657ee2..dcc98a52adbc 100644 --- a/browser/devtools/styleinspector/test/browser_styleinspector_context-menu-copy-color_02.js +++ b/browser/devtools/styleinspector/test/browser_styleinspector_context-menu-copy-color_02.js @@ -6,20 +6,17 @@ // Test "Copy color" item of the context menu #2: Test that correct color is // copied if the color changes. -const TEST_COLOR = "#123ABC"; +const TEST_URI = ` + +
Testing the color picker tooltip!
+`; add_task(function* () { - const PAGE_CONTENT = [ - '', - '
Testing the color picker tooltip!
' - ].join("\n"); - - yield addTab("data:text/html;charset=utf8,Test context menu Copy color"); - content.document.body.innerHTML = PAGE_CONTENT; + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield testCopyToClipboard(inspector, view); @@ -37,12 +34,14 @@ function* testCopyToClipboard(inspector, view) { .querySelector(".ruleview-colorswatch"); let popup = once(view._contextmenu._menupopup, "popupshown"); - EventUtils.synthesizeMouseAtCenter(element, {button: 2, type: "contextmenu"}, win); + EventUtils.synthesizeMouseAtCenter(element, {button: 2, type: "contextmenu"}, + win); yield popup; ok(!view._contextmenu.menuitemCopyColor.hidden, "Copy color is visible"); - yield waitForClipboard(() => view._contextmenu.menuitemCopyColor.click(), TEST_COLOR); + yield waitForClipboard(() => view._contextmenu.menuitemCopyColor.click(), + "#123ABC"); view._contextmenu._menupopup.hidePopup(); } @@ -52,7 +51,7 @@ function* testManualEdit(inspector, view) { let {valueSpan} = getRuleViewProperty(view, "div", "color"); - let newColor = "#C9184E" + let newColor = "#C9184E"; let editor = yield focusEditableField(view, valueSpan); info("Typing new value"); @@ -62,7 +61,8 @@ function* testManualEdit(inspector, view) { yield onBlur; yield wait(1); - let colorValueElement = getRuleViewProperty(view, "div", "color").valueSpan.firstChild; + let colorValueElement = getRuleViewProperty(view, "div", "color") + .valueSpan.firstChild; is(colorValueElement.dataset.color, newColor, "data-color was updated"); view.styleDocument.popupNode = colorValueElement; @@ -89,7 +89,8 @@ function* testColorPickerEdit(inspector, view) { let rgbaColorText = "rgba(83, 183, 89, 1)"; yield simulateColorPickerChange(view, picker, rgbaColor); - is(swatchElement.parentNode.dataset.color, rgbaColorText, "data-color was updated"); + is(swatchElement.parentNode.dataset.color, rgbaColorText, + "data-color was updated"); view.styleDocument.popupNode = swatchElement; let contextMenu = view._contextmenu; diff --git a/browser/devtools/styleinspector/test/browser_styleinspector_csslogic-content-stylesheets.js b/browser/devtools/styleinspector/test/browser_styleinspector_csslogic-content-stylesheets.js index 4b82c166bcbb..0c68b7e5dd30 100644 --- a/browser/devtools/styleinspector/test/browser_styleinspector_csslogic-content-stylesheets.js +++ b/browser/devtools/styleinspector/test/browser_styleinspector_csslogic-content-stylesheets.js @@ -7,7 +7,8 @@ // Check stylesheets on HMTL and XUL document // FIXME: this test opens the devtools for nothing, it should be changed into a -// toolkit/devtools/server/tests/mochitest/test_css-logic-...something...html test +// toolkit/devtools/server/tests/mochitest/test_css-logic-...something...html +// test const TEST_URI_HTML = TEST_URL_ROOT + "doc_content_stylesheet.html"; const TEST_URI_XUL = TEST_URL_ROOT + "doc_content_stylesheet.xul"; @@ -23,7 +24,7 @@ add_task(function*() { yield addTab(TEST_URI_HTML); let target = getNode("#target"); - let {toolbox, inspector, view} = yield openRuleView(); + let {inspector} = yield openRuleView(); yield selectNode("#target", inspector); info("Checking stylesheets"); @@ -34,7 +35,7 @@ add_task(function*() { allowXUL(); yield addTab(TEST_URI_XUL); - ({toolbox, inspector, view} = yield openRuleView()); + ({inspector} = yield openRuleView()); target = getNode("#target"); yield selectNode("#target", inspector); @@ -45,23 +46,28 @@ add_task(function*() { function allowXUL() { Cc["@mozilla.org/permissionmanager;1"].getService(Ci.nsIPermissionManager) - .addFromPrincipal(XUL_PRINCIPAL, 'allowXULXBL', Ci.nsIPermissionManager.ALLOW_ACTION); + .addFromPrincipal(XUL_PRINCIPAL, "allowXULXBL", + Ci.nsIPermissionManager.ALLOW_ACTION); } function disallowXUL() { Cc["@mozilla.org/permissionmanager;1"].getService(Ci.nsIPermissionManager) - .addFromPrincipal(XUL_PRINCIPAL, 'allowXULXBL', Ci.nsIPermissionManager.DENY_ACTION); + .addFromPrincipal(XUL_PRINCIPAL, "allowXULXBL", + Ci.nsIPermissionManager.DENY_ACTION); } function* checkSheets(target) { - let sheets = yield executeInContent("Test:GetStyleSheetsInfoForNode", {}, {target}); + let sheets = yield executeInContent("Test:GetStyleSheetsInfoForNode", {}, + {target}); for (let sheet of sheets) { if (!sheet.href || /doc_content_stylesheet_/.test(sheet.href)) { - ok(sheet.isContentSheet, sheet.href + " identified as content stylesheet"); + ok(sheet.isContentSheet, + sheet.href + " identified as content stylesheet"); } else { - ok(!sheet.isContentSheet, sheet.href + " identified as non-content stylesheet"); + ok(!sheet.isContentSheet, + sheet.href + " identified as non-content stylesheet"); } } } diff --git a/browser/devtools/styleinspector/test/browser_styleinspector_output-parser.js b/browser/devtools/styleinspector/test/browser_styleinspector_output-parser.js index a5a1b05de13f..0d5482b8d4b5 100644 --- a/browser/devtools/styleinspector/test/browser_styleinspector_output-parser.js +++ b/browser/devtools/styleinspector/test/browser_styleinspector_output-parser.js @@ -15,304 +15,283 @@ const COLOR_CLASS = "color-class"; const URL_CLASS = "url-class"; const CUBIC_BEZIER_CLASS = "bezier-class"; -function test() { - function countAll(fragment) { - return fragment.querySelectorAll("*").length; - } - function countColors(fragment) { - return fragment.querySelectorAll("." + COLOR_CLASS).length; - } - function countUrls(fragment) { - return fragment.querySelectorAll("." + URL_CLASS).length; - } - function countCubicBeziers(fragment) { - return fragment.querySelectorAll("." + CUBIC_BEZIER_CLASS).length; - } - function getColor(fragment, index) { - return fragment.querySelectorAll("." + COLOR_CLASS)[index||0].textContent; - } - function getUrl(fragment, index) { - return fragment.querySelectorAll("." + URL_CLASS)[index||0].textContent; - } - function getCubicBezier(fragment, index) { - return fragment.querySelectorAll("." + CUBIC_BEZIER_CLASS)[index||0].textContent; - } - - let testData = [ - { - name: "width", - value: "100%", - test: fragment => { - is(countAll(fragment), 0); - is(fragment.textContent, "100%"); - } - }, - { - name: "width", - value: "blue", - test: fragment => { - is(countAll(fragment), 0); - } - }, - { - name: "content", - value: "'red url(test.png) repeat top left'", - test: fragment => { - is(countAll(fragment), 0); - } - }, - { - name: "content", - value: "\"blue\"", - test: fragment => { - is(countAll(fragment), 0); - } - }, - { - name: "margin-left", - value: "url(something.jpg)", - test: fragment => { - is(countAll(fragment), 0); - } - }, - { - name: "background-color", - value: "transparent", - test: fragment => { - is(countAll(fragment), 2); - is(countColors(fragment), 1); - is(fragment.textContent, "transparent"); - } - }, - { - name: "color", - value: "red", - test: fragment => { - is(countColors(fragment), 1); - is(fragment.textContent, "red"); - } - }, - { - name: "color", - value: "#F06", - test: fragment => { - is(countColors(fragment), 1); - is(fragment.textContent, "#F06"); - } - }, - { - name: "border", - value: "80em dotted pink", - test: fragment => { - is(countAll(fragment), 2); - is(countColors(fragment), 1); - is(getColor(fragment), "pink"); - } - }, - { - name: "color", - value: "red !important", - test: fragment => { - is(countColors(fragment), 1); - is(fragment.textContent, "red !important"); - } - }, - { - name: "background", - value: "red url(test.png) repeat top left", - test: fragment => { - is(countColors(fragment), 1); - is(countUrls(fragment), 1); - is(getColor(fragment), "red"); - is(getUrl(fragment), "test.png"); - is(countAll(fragment), 3); - } - }, - { - name: "background", - value: "blue url(test.png) repeat top left !important", - test: fragment => { - is(countColors(fragment), 1); - is(countUrls(fragment), 1); - is(getColor(fragment), "blue"); - is(getUrl(fragment), "test.png"); - is(countAll(fragment), 3); - } - }, - { - name: "list-style-image", - value: "url(\"images/arrow.gif\")", - test: fragment => { - is(countAll(fragment), 1); - is(getUrl(fragment), "images/arrow.gif"); - } - }, - { - name: "list-style-image", - value: "url(\"images/arrow.gif\")!important", - test: fragment => { - is(countAll(fragment), 1); - is(getUrl(fragment), "images/arrow.gif"); - is(fragment.textContent, "url(\"images/arrow.gif\")!important"); - } - }, - { - name: "-moz-binding", - value: "url(http://somesite.com/path/to/binding.xml#someid)", - test: fragment => { - is(countAll(fragment), 1); - is(countUrls(fragment), 1); - is(getUrl(fragment), "http://somesite.com/path/to/binding.xml#someid"); - } - }, - { - name: "background", - value: "linear-gradient(to right, rgba(183,222,237,1) 0%, rgba(33,180,226,1) 30%, rgba(31,170,217,.5) 44%, #F06 75%, red 100%)", - test: fragment => { - is(countAll(fragment), 10); - let allSwatches = fragment.querySelectorAll("." + COLOR_CLASS); - is(allSwatches.length, 5); - is(allSwatches[0].textContent, "rgba(183,222,237,1)"); - is(allSwatches[1].textContent, "rgba(33,180,226,1)"); - is(allSwatches[2].textContent, "rgba(31,170,217,.5)"); - is(allSwatches[3].textContent, "#F06"); - is(allSwatches[4].textContent, "red"); - } - }, - { - name: "background", - value: "-moz-radial-gradient(center 45deg, circle closest-side, orange 0%, red 100%)", - test: fragment => { - is(countAll(fragment), 4); - let allSwatches = fragment.querySelectorAll("." + COLOR_CLASS); - is(allSwatches.length, 2); - is(allSwatches[0].textContent, "orange"); - is(allSwatches[1].textContent, "red"); - } - }, - { - name: "background", - value: "white url(http://test.com/wow_such_image.png) no-repeat top left", - test: fragment => { - is(countAll(fragment), 3); - is(countUrls(fragment), 1); - is(countColors(fragment), 1); - } - }, - { - name: "background", - value: "url(\"http://test.com/wow_such_(oh-noes)image.png?testid=1&color=red#w00t\")", - test: fragment => { - is(countAll(fragment), 1); - is(getUrl(fragment), "http://test.com/wow_such_(oh-noes)image.png?testid=1&color=red#w00t"); - } - }, - { - name: "background-image", - value: "url(this-is-an-incredible-image.jpeg)", - test: fragment => { - is(countAll(fragment), 1); - is(getUrl(fragment), "this-is-an-incredible-image.jpeg"); - } - }, - { - name: "background", - value: "red url( \"http://wow.com/cool/../../../you're(doingit)wrong\" ) repeat center", - test: fragment => { - is(countAll(fragment), 3); - is(countColors(fragment), 1); - is(getUrl(fragment), "http://wow.com/cool/../../../you're(doingit)wrong"); - } - }, - { - name: "background-image", - value: "url(../../../look/at/this/folder/structure/../../red.blue.green.svg )", - test: fragment => { - is(countAll(fragment), 1); - is(getUrl(fragment), "../../../look/at/this/folder/structure/../../red.blue.green.svg"); - } - }, - { - name: "transition-timing-function", - value: "linear", - test: fragment => { - is(countCubicBeziers(fragment), 1); - is(getCubicBezier(fragment), "linear"); - } - }, - { - name: "animation-timing-function", - value: "ease-in-out", - test: fragment => { - is(countCubicBeziers(fragment), 1); - is(getCubicBezier(fragment), "ease-in-out"); - } - }, - { - name: "animation-timing-function", - value: "cubic-bezier(.1, 0.55, .9, -3.45)", - test: fragment => { - is(countCubicBeziers(fragment), 1); - is(getCubicBezier(fragment), "cubic-bezier(.1, 0.55, .9, -3.45)"); - } - }, - { - name: "animation", - value: "move 3s cubic-bezier(.1, 0.55, .9, -3.45)", - test: fragment => { - is(countCubicBeziers(fragment), 1); - is(getCubicBezier(fragment), "cubic-bezier(.1, 0.55, .9, -3.45)"); - } - }, - { - name: "transition", - value: "top 1s ease-in", - test: fragment => { - is(countCubicBeziers(fragment), 1); - is(getCubicBezier(fragment), "ease-in"); - } - }, - { - name: "transition", - value: "top 3s steps(4, end)", - test: fragment => { - is(countAll(fragment), 0); - } - }, - { - name: "transition", - value: "top 3s step-start", - test: fragment => { - is(countAll(fragment), 0); - } - }, - { - name: "transition", - value: "top 3s step-end", - test: fragment => { - is(countAll(fragment), 0); - } - }, - { - name: "background", - value: "rgb(255, var(--g-value), 192)", - test: fragment => { - is(fragment.textContent, "rgb(255, var(--g-value), 192)"); - } - }, - { - name: "background", - value: "rgb(255, var(--g-value, 0), 192)", - test: fragment => { - is(fragment.textContent, "rgb(255, var(--g-value, 0), 192)"); - } +const TEST_DATA = [ + { + name: "width", + value: "100%", + test: fragment => { + is(countAll(fragment), 0); + is(fragment.textContent, "100%"); } - ]; + }, + { + name: "width", + value: "blue", + test: fragment => { + is(countAll(fragment), 0); + } + }, + { + name: "content", + value: "'red url(test.png) repeat top left'", + test: fragment => { + is(countAll(fragment), 0); + } + }, + { + name: "content", + value: "\"blue\"", + test: fragment => { + is(countAll(fragment), 0); + } + }, + { + name: "margin-left", + value: "url(something.jpg)", + test: fragment => { + is(countAll(fragment), 0); + } + }, + { + name: "background-color", + value: "transparent", + test: fragment => { + is(countAll(fragment), 2); + is(countColors(fragment), 1); + is(fragment.textContent, "transparent"); + } + }, + { + name: "color", + value: "red", + test: fragment => { + is(countColors(fragment), 1); + is(fragment.textContent, "red"); + } + }, + { + name: "color", + value: "#F06", + test: fragment => { + is(countColors(fragment), 1); + is(fragment.textContent, "#F06"); + } + }, + { + name: "border", + value: "80em dotted pink", + test: fragment => { + is(countAll(fragment), 2); + is(countColors(fragment), 1); + is(getColor(fragment), "pink"); + } + }, + { + name: "color", + value: "red !important", + test: fragment => { + is(countColors(fragment), 1); + is(fragment.textContent, "red !important"); + } + }, + { + name: "background", + value: "red url(test.png) repeat top left", + test: fragment => { + is(countColors(fragment), 1); + is(countUrls(fragment), 1); + is(getColor(fragment), "red"); + is(getUrl(fragment), "test.png"); + is(countAll(fragment), 3); + } + }, + { + name: "background", + value: "blue url(test.png) repeat top left !important", + test: fragment => { + is(countColors(fragment), 1); + is(countUrls(fragment), 1); + is(getColor(fragment), "blue"); + is(getUrl(fragment), "test.png"); + is(countAll(fragment), 3); + } + }, + { + name: "list-style-image", + value: "url(\"images/arrow.gif\")", + test: fragment => { + is(countAll(fragment), 1); + is(getUrl(fragment), "images/arrow.gif"); + } + }, + { + name: "list-style-image", + value: "url(\"images/arrow.gif\")!important", + test: fragment => { + is(countAll(fragment), 1); + is(getUrl(fragment), "images/arrow.gif"); + is(fragment.textContent, "url(\"images/arrow.gif\")!important"); + } + }, + { + name: "-moz-binding", + value: "url(http://somesite.com/path/to/binding.xml#someid)", + test: fragment => { + is(countAll(fragment), 1); + is(countUrls(fragment), 1); + is(getUrl(fragment), "http://somesite.com/path/to/binding.xml#someid"); + } + }, + { + name: "background", + value: "linear-gradient(to right, rgba(183,222,237,1) 0%, rgba(33,180,226,1) 30%, rgba(31,170,217,.5) 44%, #F06 75%, red 100%)", + test: fragment => { + is(countAll(fragment), 10); + let allSwatches = fragment.querySelectorAll("." + COLOR_CLASS); + is(allSwatches.length, 5); + is(allSwatches[0].textContent, "rgba(183,222,237,1)"); + is(allSwatches[1].textContent, "rgba(33,180,226,1)"); + is(allSwatches[2].textContent, "rgba(31,170,217,.5)"); + is(allSwatches[3].textContent, "#F06"); + is(allSwatches[4].textContent, "red"); + } + }, + { + name: "background", + value: "-moz-radial-gradient(center 45deg, circle closest-side, orange 0%, red 100%)", + test: fragment => { + is(countAll(fragment), 4); + let allSwatches = fragment.querySelectorAll("." + COLOR_CLASS); + is(allSwatches.length, 2); + is(allSwatches[0].textContent, "orange"); + is(allSwatches[1].textContent, "red"); + } + }, + { + name: "background", + value: "white url(http://test.com/wow_such_image.png) no-repeat top left", + test: fragment => { + is(countAll(fragment), 3); + is(countUrls(fragment), 1); + is(countColors(fragment), 1); + } + }, + { + name: "background", + value: "url(\"http://test.com/wow_such_(oh-noes)image.png?testid=1&color=red#w00t\")", + test: fragment => { + is(countAll(fragment), 1); + is(getUrl(fragment), "http://test.com/wow_such_(oh-noes)image.png?testid=1&color=red#w00t"); + } + }, + { + name: "background-image", + value: "url(this-is-an-incredible-image.jpeg)", + test: fragment => { + is(countAll(fragment), 1); + is(getUrl(fragment), "this-is-an-incredible-image.jpeg"); + } + }, + { + name: "background", + value: "red url( \"http://wow.com/cool/../../../you're(doingit)wrong\" ) repeat center", + test: fragment => { + is(countAll(fragment), 3); + is(countColors(fragment), 1); + is(getUrl(fragment), "http://wow.com/cool/../../../you're(doingit)wrong"); + } + }, + { + name: "background-image", + value: "url(../../../look/at/this/folder/structure/../../red.blue.green.svg )", + test: fragment => { + is(countAll(fragment), 1); + is(getUrl(fragment), "../../../look/at/this/folder/structure/../../red.blue.green.svg"); + } + }, + { + name: "transition-timing-function", + value: "linear", + test: fragment => { + is(countCubicBeziers(fragment), 1); + is(getCubicBezier(fragment), "linear"); + } + }, + { + name: "animation-timing-function", + value: "ease-in-out", + test: fragment => { + is(countCubicBeziers(fragment), 1); + is(getCubicBezier(fragment), "ease-in-out"); + } + }, + { + name: "animation-timing-function", + value: "cubic-bezier(.1, 0.55, .9, -3.45)", + test: fragment => { + is(countCubicBeziers(fragment), 1); + is(getCubicBezier(fragment), "cubic-bezier(.1, 0.55, .9, -3.45)"); + } + }, + { + name: "animation", + value: "move 3s cubic-bezier(.1, 0.55, .9, -3.45)", + test: fragment => { + is(countCubicBeziers(fragment), 1); + is(getCubicBezier(fragment), "cubic-bezier(.1, 0.55, .9, -3.45)"); + } + }, + { + name: "transition", + value: "top 1s ease-in", + test: fragment => { + is(countCubicBeziers(fragment), 1); + is(getCubicBezier(fragment), "ease-in"); + } + }, + { + name: "transition", + value: "top 3s steps(4, end)", + test: fragment => { + is(countAll(fragment), 0); + } + }, + { + name: "transition", + value: "top 3s step-start", + test: fragment => { + is(countAll(fragment), 0); + } + }, + { + name: "transition", + value: "top 3s step-end", + test: fragment => { + is(countAll(fragment), 0); + } + }, + { + name: "background", + value: "rgb(255, var(--g-value), 192)", + test: fragment => { + is(fragment.textContent, "rgb(255, var(--g-value), 192)"); + } + }, + { + name: "background", + value: "rgb(255, var(--g-value, 0), 192)", + test: fragment => { + is(fragment.textContent, "rgb(255, var(--g-value, 0), 192)"); + } + } +]; +add_task(function*() { let parser = new OutputParser(document); - for (let i = 0; i < testData.length; i ++) { - let data = testData[i]; - info("Output-parser test data " + i + ". {" + data.name + " : " + data.value + ";}"); + for (let i = 0; i < TEST_DATA.length; i++) { + let data = TEST_DATA[i]; + info("Output-parser test data " + i + ". {" + data.name + " : " + + data.value + ";}"); data.test(parser.parseCssProperty(data.name, data.value, { colorClass: COLOR_CLASS, urlClass: URL_CLASS, @@ -320,6 +299,27 @@ function test() { defaultColorType: false })); } +}); - finish(); +function countAll(fragment) { + return fragment.querySelectorAll("*").length; +} +function countColors(fragment) { + return fragment.querySelectorAll("." + COLOR_CLASS).length; +} +function countUrls(fragment) { + return fragment.querySelectorAll("." + URL_CLASS).length; +} +function countCubicBeziers(fragment) { + return fragment.querySelectorAll("." + CUBIC_BEZIER_CLASS).length; +} +function getColor(fragment, index) { + return fragment.querySelectorAll("." + COLOR_CLASS)[index||0].textContent; +} +function getUrl(fragment, index) { + return fragment.querySelectorAll("." + URL_CLASS)[index||0].textContent; +} +function getCubicBezier(fragment, index) { + return fragment.querySelectorAll("." + CUBIC_BEZIER_CLASS)[index||0] + .textContent; } diff --git a/browser/devtools/styleinspector/test/browser_styleinspector_refresh_when_active.js b/browser/devtools/styleinspector/test/browser_styleinspector_refresh_when_active.js index 5a2205ef5631..08f3caff1b80 100644 --- a/browser/devtools/styleinspector/test/browser_styleinspector_refresh_when_active.js +++ b/browser/devtools/styleinspector/test/browser_styleinspector_refresh_when_active.js @@ -6,21 +6,21 @@ // Test that the style-inspector views only refresh when they are active. -const TEST_URL = 'data:text/html;charset=utf-8,' + - '
one
' + - '
two
'; +const TEST_URI = ` +
one
+
two
+`; add_task(function*() { - yield addTab(TEST_URL); - - info("Opening the rule-view and selecting test node one"); - let {inspector, view: rView} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("#one", inspector); - is(getRuleViewPropertyValue(rView, "element", "color"), "#F00", + is(getRuleViewPropertyValue(view, "element", "color"), "#F00", "The rule-view shows the properties for test node one"); - let cView = inspector.sidebar.getWindowForTab("computedview")["computedview"].view; + let cView = inspector.sidebar.getWindowForTab("computedview") + .computedview.view; let prop = getComputedViewProperty(cView, "color"); ok(!prop, "The computed-view doesn't show the properties for test node one"); @@ -38,6 +38,6 @@ add_task(function*() { ok(getComputedViewPropertyValue(cView, "color"), "#00F", "The computed-view shows the properties for test node two"); - is(getRuleViewPropertyValue(rView, "element", "color"), "#F00", + is(getRuleViewPropertyValue(view, "element", "color"), "#F00", "The rule-view doesn't the properties for test node two"); -}); \ No newline at end of file +}); diff --git a/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-background-image.js b/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-background-image.js index dd4fad3378de..e1ed28778344 100644 --- a/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-background-image.js +++ b/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-background-image.js @@ -7,28 +7,27 @@ // Test that background-image URLs have image preview tooltips in the rule-view // and computed-view -const PAGE_CONTENT = [ - '', - '
test element
' -].join("\n"); +const TEST_URI = ` + +
test element
+`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,rule view tooltip test"); - content.document.body.innerHTML = PAGE_CONTENT; - let {toolbox, inspector, view} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); info("Testing the background-image property on the body rule"); yield testBodyRuleView(view); @@ -38,7 +37,8 @@ add_task(function*() { info("Testing the the background property on the .test-element rule"); yield testDivRuleView(view); - info("Testing that image preview tooltips show even when there are fields being edited"); + info("Testing that image preview tooltips show even when there are " + + "fields being edited"); yield testTooltipAppearsEvenInEditMode(view); info("Switching over to the computed-view"); @@ -54,7 +54,8 @@ function* testBodyRuleView(view) { info("Testing tooltips in the rule view"); let panel = view.tooltips.previewTooltip.panel; - // Check that the rule view has a tooltip and that a XUL panel has been created + // Check that the rule view has a tooltip and that a XUL panel has + // been created ok(view.tooltips.previewTooltip, "Tooltip instance exists"); ok(panel, "XUL panel exists"); @@ -66,7 +67,8 @@ function* testBodyRuleView(view) { let images = panel.getElementsByTagName("image"); is(images.length, 1, "Tooltip contains an image"); - ok(images[0].getAttribute("src").indexOf("iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHe") !== -1, + ok(images[0].getAttribute("src") + .indexOf("iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHe") !== -1, "The image URL seems fine"); } @@ -81,12 +83,11 @@ function* testDivRuleView(view) { let images = panel.getElementsByTagName("image"); is(images.length, 1, "Tooltip contains an image"); - ok(images[0].getAttribute("src").startsWith("data:"), "Tooltip contains a data-uri image as expected"); + ok(images[0].getAttribute("src").startsWith("data:"), + "Tooltip contains a data-uri image as expected"); } function* testTooltipAppearsEvenInEditMode(view) { - let panel = view.tooltips.previewTooltip.panel; - info("Switching to edit mode in the rule view"); let editor = yield turnToEditMode(view); @@ -119,5 +120,6 @@ function* testComputedView(view) { let images = panel.getElementsByTagName("image"); is(images.length, 1, "Tooltip contains an image"); - ok(images[0].getAttribute("src").startsWith("data:"), "Tooltip contains a data-uri in the computed-view too"); + ok(images[0].getAttribute("src").startsWith("data:"), + "Tooltip contains a data-uri in the computed-view too"); } diff --git a/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-closes-on-new-selection.js b/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-closes-on-new-selection.js index 11ae65f87889..0c0572095105 100644 --- a/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-closes-on-new-selection.js +++ b/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-closes-on-new-selection.js @@ -6,10 +6,11 @@ // Test that if a tooltip is visible when a new selection is made, it closes -add_task(function*() { - yield addTab("data:text/html;charset=utf-8,
el 1
el 2
"); +const TEST_URI = "
el 1
el 2
"; - let {toolbox, inspector, view} = yield openRuleView(); +add_task(function*() { + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode(".one", inspector); info("Testing rule view tooltip closes on new selection"); @@ -30,6 +31,7 @@ function* testRuleView(ruleView, inspector) { info("Selecting a new node"); let onHidden = tooltip.once("hidden"); yield selectNode(".two", inspector); + yield onHidden; ok(true, "Rule view tooltip closed after a new node got selected"); } @@ -44,6 +46,7 @@ function* testComputedView(computedView, inspector) { info("Selecting a new node"); let onHidden = tooltip.once("hidden"); yield selectNode(".one", inspector); + yield onHidden; ok(true, "Computed view tooltip closed after a new node got selected"); } diff --git a/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-longhand-fontfamily.js b/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-longhand-fontfamily.js index d188f13cd598..196eeda948cb 100644 --- a/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-longhand-fontfamily.js +++ b/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-longhand-fontfamily.js @@ -6,34 +6,26 @@ // Test the fontfamily tooltip on longhand properties -const PAGE_CONTENT = [ - '', - '
test element
' -].join("\n"); +const TEST_URI = ` + +
test element
+`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,font family longhand tooltip test"); - - info("Creating the test document"); - content.document.body.innerHTML = PAGE_CONTENT; - - info("Opening the rule view"); - let {toolbox, inspector, view} = yield openRuleView(); - - info("Selecting the test node"); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("#testElement", inspector); - yield testRuleView(view, inspector.selection.nodeFront); info("Opening the computed view"); let onComputedViewReady = inspector.once("computed-view-refreshed"); - ({toolbox, inspector, view} = yield openComputedView()); + ({inspector, view} = yield openComputedView()); yield onComputedViewReady; yield testComputedView(view, inspector.selection.nodeFront); @@ -47,22 +39,26 @@ function* testRuleView(ruleView, nodeFront) { let tooltip = ruleView.tooltips.previewTooltip; let panel = tooltip.panel; - // Check that the rule view has a tooltip and that a XUL panel has been created + // Check that the rule view has a tooltip and that a XUL panel has + // been created ok(tooltip, "Tooltip instance exists"); ok(panel, "XUL panel exists"); // Get the font family property inside the rule view - let {valueSpan} = getRuleViewProperty(ruleView, "#testElement", "font-family"); + let {valueSpan} = getRuleViewProperty(ruleView, "#testElement", + "font-family"); // And verify that the tooltip gets shown on this property yield assertHoverTooltipOn(tooltip, valueSpan); let images = panel.getElementsByTagName("image"); is(images.length, 1, "Tooltip contains an image"); - ok(images[0].getAttribute("src").startsWith("data:"), "Tooltip contains a data-uri image as expected"); + ok(images[0].getAttribute("src").startsWith("data:"), + "Tooltip contains a data-uri image as expected"); let dataURL = yield getFontFamilyDataURL(valueSpan.textContent, nodeFront); - is(images[0].getAttribute("src"), dataURL, "Tooltip contains the correct data-uri image"); + is(images[0].getAttribute("src"), dataURL, + "Tooltip contains the correct data-uri image"); } function* testComputedView(computedView, nodeFront) { @@ -76,14 +72,17 @@ function* testComputedView(computedView, nodeFront) { let images = panel.getElementsByTagName("image"); is(images.length, 1, "Tooltip contains an image"); - ok(images[0].getAttribute("src").startsWith("data:"), "Tooltip contains a data-uri image as expected"); + ok(images[0].getAttribute("src").startsWith("data:"), + "Tooltip contains a data-uri image as expected"); let dataURL = yield getFontFamilyDataURL(valueSpan.textContent, nodeFront); - is(images[0].getAttribute("src"), dataURL, "Tooltip contains the correct data-uri image"); + is(images[0].getAttribute("src"), dataURL, + "Tooltip contains the correct data-uri image"); } function* testExpandedComputedViewProperty(computedView, nodeFront) { - info("Testing font-family tooltips in expanded properties of the computed view"); + info("Testing font-family tooltips in expanded properties of the " + + "computed view"); info("Expanding the font-family property to reveal matched selectors"); let propertyView = getPropertyView(computedView, "font-family"); @@ -100,10 +99,12 @@ function* testExpandedComputedViewProperty(computedView, nodeFront) { let images = panel.getElementsByTagName("image"); is(images.length, 1, "Tooltip contains an image"); - ok(images[0].getAttribute("src").startsWith("data:"), "Tooltip contains a data-uri image as expected"); + ok(images[0].getAttribute("src").startsWith("data:"), + "Tooltip contains a data-uri image as expected"); let dataURL = yield getFontFamilyDataURL(valueSpan.textContent, nodeFront); - is(images[0].getAttribute("src"), dataURL, "Tooltip contains the correct data-uri image"); + is(images[0].getAttribute("src"), dataURL, + "Tooltip contains the correct data-uri image"); } function getPropertyView(computedView, name) { diff --git a/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-shorthand-fontfamily.js b/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-shorthand-fontfamily.js index 6be03806bb53..0da1d9479313 100644 --- a/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-shorthand-fontfamily.js +++ b/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-shorthand-fontfamily.js @@ -6,27 +6,19 @@ // Test the fontfamily tooltip on shorthand properties -const PAGE_CONTENT = [ - '', - '
test element
' -].join("\n"); +const TEST_URI = ` + +
test element
+`; add_task(function*() { - yield addTab("data:text/html;charset=utf-8,font family shorthand tooltip test"); - - info("Creating the test document"); - content.document.body.innerHTML = PAGE_CONTENT; - - info("Opening the rule view"); - let {toolbox, inspector, view} = yield openRuleView(); - - info("Selecting the test node"); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("#testElement", inspector); - yield testRuleView(view, inspector.selection.nodeFront); }); @@ -36,25 +28,30 @@ function* testRuleView(ruleView, nodeFront) { let tooltip = ruleView.tooltips.previewTooltip; let panel = tooltip.panel; - // Check that the rule view has a tooltip and that a XUL panel has been created + // Check that the rule view has a tooltip and that a XUL panel has + // been created ok(tooltip, "Tooltip instance exists"); ok(panel, "XUL panel exists"); // Get the computed font family property inside the font rule view - let propertyList = ruleView.element.querySelectorAll(".ruleview-propertylist"); + let propertyList = ruleView.element + .querySelectorAll(".ruleview-propertylist"); let fontExpander = propertyList[1].querySelectorAll(".ruleview-expander")[0]; fontExpander.click(); let rule = getRuleViewRule(ruleView, "#testElement"); - let valueSpan = rule.querySelector(".ruleview-computed .ruleview-propertyvalue"); + let valueSpan = rule + .querySelector(".ruleview-computed .ruleview-propertyvalue"); // And verify that the tooltip gets shown on this property yield assertHoverTooltipOn(tooltip, valueSpan); let images = panel.getElementsByTagName("image"); is(images.length, 1, "Tooltip contains an image"); - ok(images[0].getAttribute("src").startsWith("data:"), "Tooltip contains a data-uri image as expected"); + ok(images[0].getAttribute("src") + .startsWith("data:"), "Tooltip contains a data-uri image as expected"); let dataURL = yield getFontFamilyDataURL(valueSpan.textContent, nodeFront); - is(images[0].getAttribute("src"), dataURL, "Tooltip contains the correct data-uri image"); + is(images[0].getAttribute("src"), dataURL, + "Tooltip contains the correct data-uri image"); } diff --git a/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-size.js b/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-size.js index ecdc1b969aa5..4d481647d29a 100644 --- a/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-size.js +++ b/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-size.js @@ -7,23 +7,20 @@ // Checking tooltips dimensions, to make sure their big enough to display their // content -const TEST_PAGE = [ - 'data:text/html;charset=utf-8,', - '', - '
' -].join("\n"); +const TEST_URI = ` + +
+`; add_task(function*() { - yield addTab(TEST_PAGE); - let {toolbox, inspector, view} = yield openRuleView(); - + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode("div", inspector); - yield testImageDimension(view); yield testPickerDimension(view); }); diff --git a/browser/devtools/styleinspector/test/browser_styleinspector_transform-highlighter-01.js b/browser/devtools/styleinspector/test/browser_styleinspector_transform-highlighter-01.js index d9e018bc16de..295c6dec691c 100644 --- a/browser/devtools/styleinspector/test/browser_styleinspector_transform-highlighter-01.js +++ b/browser/devtools/styleinspector/test/browser_styleinspector_transform-highlighter-01.js @@ -6,29 +6,30 @@ // Test that the css transform highlighter is created only when asked -const PAGE_CONTENT = [ - '', - 'Test the css transform highlighter' -].join("\n"); +const TEST_URI = ` + + Test the css transform highlighter +`; const TYPE = "CssTransformHighlighter"; add_task(function*() { - yield addTab("data:text/html;charset=utf-8," + PAGE_CONTENT); - - let {inspector, view: rView} = yield openRuleView(); - let overlay = rView.highlighters; + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); + let overlay = view.highlighters; ok(!overlay.highlighters[TYPE], "No highlighter exists in the rule-view"); let h = yield overlay._getHighlighter(TYPE); - ok(overlay.highlighters[TYPE], "The highlighter has been created in the rule-view"); + ok(overlay.highlighters[TYPE], + "The highlighter has been created in the rule-view"); is(h, overlay.highlighters[TYPE], "The right highlighter has been created"); let h2 = yield overlay._getHighlighter(TYPE); - is(h, h2, "The same instance of highlighter is returned everytime in the rule-view"); + is(h, h2, + "The same instance of highlighter is returned everytime in the rule-view"); let onComputedViewReady = inspector.once("computed-view-refreshed"); let {view: cView} = yield openComputedView(); @@ -37,8 +38,10 @@ add_task(function*() { ok(!overlay.highlighters[TYPE], "No highlighter exists in the computed-view"); h = yield overlay._getHighlighter(TYPE); - ok(overlay.highlighters[TYPE], "The highlighter has been created in the computed-view"); + ok(overlay.highlighters[TYPE], + "The highlighter has been created in the computed-view"); is(h, overlay.highlighters[TYPE], "The right highlighter has been created"); h2 = yield overlay._getHighlighter(TYPE); - is(h, h2, "The same instance of highlighter is returned everytime in the computed-view"); + is(h, h2, "The same instance of highlighter is returned everytime " + + "in the computed-view"); }); diff --git a/browser/devtools/styleinspector/test/browser_styleinspector_transform-highlighter-02.js b/browser/devtools/styleinspector/test/browser_styleinspector_transform-highlighter-02.js index 64d8f0bb6666..a319b1dfe1e8 100644 --- a/browser/devtools/styleinspector/test/browser_styleinspector_transform-highlighter-02.js +++ b/browser/devtools/styleinspector/test/browser_styleinspector_transform-highlighter-02.js @@ -7,35 +7,36 @@ // Test that the css transform highlighter is created when hovering over a // transform property -const PAGE_CONTENT = [ - '', - 'Test the css transform highlighter' -].join("\n"); +const TEST_URI = ` + + Test the css transform highlighter +`; let TYPE = "CssTransformHighlighter"; add_task(function*() { - yield addTab("data:text/html;charset=utf-8," + PAGE_CONTENT); - - let {inspector, view: rView} = yield openRuleView(); - let hs = rView.highlighters; + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); + let hs = view.highlighters; ok(!hs.highlighters[TYPE], "No highlighter exists in the rule-view (1)"); - ok(!hs.promises[TYPE], "No highlighter is being created in the rule-view (1)"); + ok(!hs.promises[TYPE], + "No highlighter is being created in the rule-view (1)"); info("Faking a mousemove on a non-transform property"); - let {valueSpan} = getRuleViewProperty(rView, "body", "color"); + let {valueSpan} = getRuleViewProperty(view, "body", "color"); hs._onMouseMove({target: valueSpan}); ok(!hs.highlighters[TYPE], "No highlighter exists in the rule-view (2)"); - ok(!hs.promises[TYPE], "No highlighter is being created in the rule-view (2)"); + ok(!hs.promises[TYPE], + "No highlighter is being created in the rule-view (2)"); info("Faking a mousemove on a transform property"); - ({valueSpan} = getRuleViewProperty(rView, "body", "transform")); + ({valueSpan} = getRuleViewProperty(view, "body", "transform")); let onHighlighterShown = hs.once("highlighter-shown"); hs._onMouseMove({target: valueSpan}); yield onHighlighterShown; @@ -49,13 +50,15 @@ add_task(function*() { hs = cView.highlighters; ok(!hs.highlighters[TYPE], "No highlighter exists in the computed-view (1)"); - ok(!hs.promises[TYPE], "No highlighter is being created in the computed-view (1)"); + ok(!hs.promises[TYPE], + "No highlighter is being created in the computed-view (1)"); info("Faking a mousemove on a non-transform property"); ({valueSpan} = getComputedViewProperty(cView, "color")); hs._onMouseMove({target: valueSpan}); ok(!hs.highlighters[TYPE], "No highlighter exists in the computed-view (2)"); - ok(!hs.promises[TYPE], "No highlighter is being created in the computed-view (2)"); + ok(!hs.promises[TYPE], + "No highlighter is being created in the computed-view (2)"); info("Faking a mousemove on a transform property"); ({valueSpan} = getComputedViewProperty(cView, "transform")); diff --git a/browser/devtools/styleinspector/test/browser_styleinspector_transform-highlighter-03.js b/browser/devtools/styleinspector/test/browser_styleinspector_transform-highlighter-03.js index 06041c412ea3..72b687ec0bbb 100644 --- a/browser/devtools/styleinspector/test/browser_styleinspector_transform-highlighter-03.js +++ b/browser/devtools/styleinspector/test/browser_styleinspector_transform-highlighter-03.js @@ -10,25 +10,24 @@ // Note that in this test, we mock the highlighter front, merely testing the // behavior of the style-inspector UI for now -const PAGE_CONTENT = [ - '', - 'Test the css transform highlighter' -].join("\n"); +const TEST_URI = ` + + Test the css transform highlighter +`; const TYPE = "CssTransformHighlighter"; add_task(function*() { - yield addTab("data:text/html;charset=utf-8," + PAGE_CONTENT); - - let {inspector, view: rView} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); // Mock the highlighter front to get the reference of the NodeFront let HighlighterFront = { @@ -49,10 +48,10 @@ add_task(function*() { }; // Inject the mock highlighter in the rule-view - let hs = rView.highlighters; + let hs = view.highlighters; hs.promises[TYPE] = promise.resolve(HighlighterFront); - let {valueSpan} = getRuleViewProperty(rView, "body", "transform"); + let {valueSpan} = getRuleViewProperty(view, "body", "transform"); info("Checking that the HighlighterFront's show/hide methods are called"); let onHighlighterShown = hs.once("highlighter-shown"); @@ -78,7 +77,7 @@ add_task(function*() { info("Checking that the right NodeFront reference is passed"); yield selectNode("html", inspector); - ({valueSpan} = getRuleViewProperty(rView, "html", "transform")); + ({valueSpan} = getRuleViewProperty(view, "html", "transform")); onHighlighterShown = hs.once("highlighter-shown"); hs._onMouseMove({target: valueSpan}); yield onHighlighterShown; @@ -86,15 +85,16 @@ add_task(function*() { "The right NodeFront is passed to the highlighter (1)"); yield selectNode("body", inspector); - ({valueSpan} = getRuleViewProperty(rView, "body", "transform")); + ({valueSpan} = getRuleViewProperty(view, "body", "transform")); onHighlighterShown = hs.once("highlighter-shown"); hs._onMouseMove({target: valueSpan}); yield onHighlighterShown; is(HighlighterFront.nodeFront.tagName, "BODY", "The right NodeFront is passed to the highlighter (2)"); - info("Checking that the highlighter gets hidden when hovering a non-transform property"); - ({valueSpan} = getRuleViewProperty(rView, "body", "color")); + info("Checking that the highlighter gets hidden when hovering a " + + "non-transform property"); + ({valueSpan} = getRuleViewProperty(view, "body", "color")); onHighlighterHidden = hs.once("highlighter-hidden"); hs._onMouseMove({target: valueSpan}); yield onHighlighterHidden; diff --git a/browser/devtools/styleinspector/test/browser_styleinspector_transform-highlighter-04.js b/browser/devtools/styleinspector/test/browser_styleinspector_transform-highlighter-04.js index ae253f37ae57..0e3d7ef8a5ef 100644 --- a/browser/devtools/styleinspector/test/browser_styleinspector_transform-highlighter-04.js +++ b/browser/devtools/styleinspector/test/browser_styleinspector_transform-highlighter-04.js @@ -11,50 +11,51 @@ // tests, this one only tests the rule-view as only this view features disabled // and overriden properties -const PAGE_CONTENT = [ - '', - '
' -].join("\n"); +const TEST_URI = ` + +
+`; const TYPE = "CssTransformHighlighter"; add_task(function*() { - yield addTab("data:text/html;charset=utf-8," + PAGE_CONTENT); - - let {view: rView, inspector} = yield openRuleView(); + yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let {inspector, view} = yield openRuleView(); yield selectNode(".test", inspector); - let hs = rView.highlighters; + let hs = view.highlighters; info("Faking a mousemove on the overriden property"); - let {valueSpan} = getRuleViewProperty(rView, "div", "transform"); + let {valueSpan} = getRuleViewProperty(view, "div", "transform"); hs._onMouseMove({target: valueSpan}); - ok(!hs.highlighters[TYPE], "No highlighter was created for the overriden property"); + ok(!hs.highlighters[TYPE], + "No highlighter was created for the overriden property"); ok(!hs.promises[TYPE], "And no highlighter is being initialized either"); info("Disabling the applied property"); - let classRuleEditor = getRuleViewRuleEditor(rView, 1); + let classRuleEditor = getRuleViewRuleEditor(view, 1); let propEditor = classRuleEditor.rule.textProps[0].editor; propEditor.enable.click(); yield classRuleEditor.rule._applyingModifications; info("Faking a mousemove on the disabled property"); - ({valueSpan} = getRuleViewProperty(rView, ".test", "transform")); + ({valueSpan} = getRuleViewProperty(view, ".test", "transform")); hs._onMouseMove({target: valueSpan}); - ok(!hs.highlighters[TYPE], "No highlighter was created for the disabled property"); + ok(!hs.highlighters[TYPE], + "No highlighter was created for the disabled property"); ok(!hs.promises[TYPE], "And no highlighter is being initialized either"); info("Faking a mousemove on the now unoverriden property"); - ({valueSpan} = getRuleViewProperty(rView, "div", "transform")); + ({valueSpan} = getRuleViewProperty(view, "div", "transform")); let onHighlighterShown = hs.once("highlighter-shown"); hs._onMouseMove({target: valueSpan}); yield onHighlighterShown; diff --git a/browser/devtools/styleinspector/test/head.js b/browser/devtools/styleinspector/test/head.js index c70aba22e705..679f16f55ec2 100644 --- a/browser/devtools/styleinspector/test/head.js +++ b/browser/devtools/styleinspector/test/head.js @@ -13,14 +13,18 @@ let {CssRuleView, _ElementStyle} = require("devtools/styleinspector/rule-view"); let {CssLogic, CssSelector} = require("devtools/styleinspector/css-logic"); let DevToolsUtils = require("devtools/toolkit/DevToolsUtils"); let {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm", {}); -let {editableField, getInplaceEditorForSpan: inplaceEditor} = require("devtools/shared/inplace-editor"); -let {console} = Components.utils.import("resource://gre/modules/devtools/Console.jsm", {}); +let {editableField, getInplaceEditorForSpan: inplaceEditor} = + require("devtools/shared/inplace-editor"); +let {console} = + Components.utils.import("resource://gre/modules/devtools/Console.jsm", {}); // All tests are asynchronous waitForExplicitFinish(); -const TEST_URL_ROOT = "http://example.com/browser/browser/devtools/styleinspector/test/"; -const TEST_URL_ROOT_SSL = "https://example.com/browser/browser/devtools/styleinspector/test/"; +const TEST_URL_ROOT = + "http://example.com/browser/browser/devtools/styleinspector/test/"; +const TEST_URL_ROOT_SSL = + "https://example.com/browser/browser/devtools/styleinspector/test/"; const ROOT_TEST_DIR = getRootDirectory(gTestPath); const FRAME_SCRIPT_URL = ROOT_TEST_DIR + "doc_frame_script.js"; @@ -73,12 +77,12 @@ registerCleanupFunction(() => { * There is no need to clean tabs up at the end of a test as this is done * automatically. * - * It is advised not to store any references on the global scope. There shouldn't - * be a need to anyway. Thanks to add_task, test steps, even though asynchronous, - * can be described in a nice flat way, and if/for/while/... control flow can be - * used as in sync code, making it possible to write the outline of the test case - * all in add_task, and delegate actual processing and assertions to other - * functions. + * It is advised not to store any references on the global scope. There + * shouldn't be a need to anyway. Thanks to add_task, test steps, even + * though asynchronous, can be described in a nice flat way, and + * if/for/while/... control flow can be used as in sync code, making it + * possible to write the outline of the test case all in add_task, and delegate + * actual processing and assertions to other functions. */ /* ********************************************* @@ -91,7 +95,9 @@ registerCleanupFunction(() => { /** * Add a new test tab in the browser and load the given url. - * @param {String} url The url to be loaded in the new tab + * + * @param {String} url + * The url to be loaded in the new tab * @return a promise that resolves to the tab object when the url is loaded */ function addTab(url) { @@ -119,6 +125,7 @@ function addTab(url) { /** * Simple DOM node accesor function that takes either a node or a string css * selector as argument and returns the corresponding node + * * @param {String|DOMNode} nodeOrSelector * @return {DOMNode|CPOW} Note that in e10s mode a CPOW object is returned which * doesn't implement *all* of the DOMNode's properties @@ -132,9 +139,10 @@ function getNode(nodeOrSelector) { /** * Get the NodeFront for a given css selector, via the protocol + * * @param {String} selector - * @param {InspectorPanel} inspector The instance of InspectorPanel currently - * loaded in the toolbox + * @param {InspectorPanel} inspector + * The instance of InspectorPanel currently loaded in the toolbox * @return {Promise} Resolves to the NodeFront instance */ function getNodeFront(selector, {walker}) { @@ -144,9 +152,10 @@ function getNodeFront(selector, {walker}) { /** * Highlight a node that matches the given css selector and set the inspector's * current selection to this node. + * * @param {String} selector - * @param {InspectorPanel} inspector The instance of InspectorPanel currently - * loaded in the toolbox + * @param {InspectorPanel} inspector + * The instance of InspectorPanel currently loaded in the toolbox * @return {Promise} Resolves when the inspector is updated with the new node */ let selectAndHighlightNode = Task.async(function*(selector, inspector) { @@ -161,11 +170,11 @@ let selectAndHighlightNode = Task.async(function*(selector, inspector) { /* * Set the inspector's current selection to a node or to the first match of the * given css selector. - * @param {String|NodeFront} - * data The node to select + * + * @param {String|NodeFront} data + * The node to select * @param {InspectorPanel} inspector - * The instance of InspectorPanel currently - * loaded in the toolbox + * The instance of InspectorPanel currently loaded in the toolbox * @param {String} reason * Defaults to "test" which instructs the inspector not * to highlight the node upon selection @@ -184,8 +193,9 @@ let selectNode = Task.async(function*(data, inspector, reason="test") { /** * Set the inspector's current selection to null so that no node is selected - * @param {InspectorPanel} inspector The instance of InspectorPanel currently - * loaded in the toolbox + * + * @param {InspectorPanel} inspector + * The instance of InspectorPanel currently loaded in the toolbox * @return a promise that resolves when the inspector is updated */ function clearCurrentNodeSelection(inspector) { @@ -197,6 +207,7 @@ function clearCurrentNodeSelection(inspector) { /** * Open the toolbox, with the inspector tool visible. + * * @return a promise that resolves when the inspector is ready */ let openInspector = Task.async(function*() { @@ -236,6 +247,7 @@ let openInspector = Task.async(function*() { /** * Wait for the toolbox frame to receive focus after it loads + * * @param {Toolbox} toolbox * @return a promise that resolves when focus has been received */ @@ -250,6 +262,7 @@ function waitForToolboxFrameFocus(toolbox) { /** * Open the toolbox, with the inspector tool visible, and the sidebar that * corresponds to the given id selected + * * @return a promise that resolves when the inspector is ready and the sidebar * view is visible and ready */ @@ -274,6 +287,7 @@ let openInspectorSideBar = Task.async(function*(id) { /** * Open the toolbox, with the inspector tool visible, and the computed-view * sidebar tab selected. + * * @return a promise that resolves when the inspector is ready and the computed * view is visible and ready */ @@ -284,6 +298,7 @@ function openComputedView() { /** * Open the toolbox, with the inspector tool visible, and the rule-view * sidebar tab selected. + * * @return a promise that resolves when the inspector is ready and the rule * view is visible and ready */ @@ -293,10 +308,13 @@ function openRuleView() { /** * Wait for eventName on target. - * @param {Object} target An observable object that either supports on/off or - * addEventListener/removeEventListener + * + * @param {Object} target + * An observable object that either supports on/off or + * addEventListener/removeEventListener * @param {String} eventName - * @param {Boolean} useCapture Optional, for addEventListener/removeEventListener + * @param {Boolean} useCapture + * Optional, for addEventListener/removeEventListener * @return A promise that resolves when the event has been handled */ function once(target, eventName, useCapture=false) { @@ -324,7 +342,9 @@ function once(target, eventName, useCapture=false) { /** * This shouldn't be used in the tests, but is useful when writing new tests or * debugging existing tests in order to introduce delays in the test steps - * @param {Number} ms The time to wait + * + * @param {Number} ms + * The time to wait * @return A promise that resolves when the time is passed */ function wait(ms) { @@ -336,7 +356,9 @@ function wait(ms) { /** * Wait for a content -> chrome message on the message manager (the window * messagemanager is used). - * @param {String} name The message name + * + * @param {String} name + * The message name * @return {Promise} A promise that resolves to the response data when the * message has been received */ @@ -356,12 +378,17 @@ function waitForContentMessage(name) { /** * Send an async message to the frame script (chrome -> content) and wait for a * response message with the same name (content -> chrome). - * @param {String} name The message name. Should be one of the messages defined - * in doc_frame_script.js - * @param {Object} data Optional data to send along - * @param {Object} objects Optional CPOW objects to send along - * @param {Boolean} expectResponse If set to false, don't wait for a response - * with the same name from the content script. Defaults to true. + * + * @param {String} name + * The message name. Should be one of the messages defined + * in doc_frame_script.js + * @param {Object} data + * Optional data to send along + * @param {Object} objects + * Optional CPOW objects to send along + * @param {Boolean} expectResponse + * If set to false, don't wait for a response with the same name + * from the content script. Defaults to true. * @return {Promise} Resolves to the response data if a response is expected, * immediately resolves otherwise */ @@ -372,21 +399,25 @@ function executeInContent(name, data={}, objects={}, expectResponse=true) { mm.sendAsyncMessage(name, data, objects); if (expectResponse) { return waitForContentMessage(name); - } else { - return promise.resolve(); } + + return promise.resolve(); } /** * Send an async message to the frame script and get back the requested * computed style property. - * @param {String} selector: The selector used to obtain the element. - * @param {String} pseudo: pseudo id to query, or null. - * @param {String} name: name of the property. + * + * @param {String} selector + * The selector used to obtain the element. + * @param {String} pseudo + * pseudo id to query, or null. + * @param {String} name + * name of the property. */ function* getComputedStyleProperty(selector, pseudo, propName) { - return yield executeInContent("Test:GetComputedStylePropertyValue", - {selector, + return yield executeInContent("Test:GetComputedStylePropertyValue", + {selector, pseudo, name: propName}); } @@ -394,15 +425,21 @@ function* getComputedStyleProperty(selector, pseudo, propName) { /** * Send an async message to the frame script and wait until the requested * computed style property has the expected value. - * @param {String} selector: The selector used to obtain the element. - * @param {String} pseudo: pseudo id to query, or null. - * @param {String} prop: name of the property. - * @param {String} expected: expected value of property - * @param {String} name: the name used in test message + * + * @param {String} selector + * The selector used to obtain the element. + * @param {String} pseudo + * pseudo id to query, or null. + * @param {String} prop + * name of the property. + * @param {String} expected + * expected value of property + * @param {String} name + * the name used in test message */ function* waitForComputedStyleProperty(selector, pseudo, name, expected) { - return yield executeInContent("Test:WaitForComputedStylePropertyValue", - {selector, + return yield executeInContent("Test:WaitForComputedStylePropertyValue", + {selector, pseudo, expected, name}); @@ -411,9 +448,11 @@ function* waitForComputedStyleProperty(selector, pseudo, name, expected) { /** * Given an inplace editable element, click to switch it to edit mode, wait for * focus + * * @return a promise that resolves to the inplace-editor element when ready */ -let focusEditableField = Task.async(function*(ruleView, editable, xOffset=1, yOffset=1, options={}) { +let focusEditableField = Task.async(function*(ruleView, editable, xOffset=1, + yOffset=1, options={}) { let onFocus = once(editable.parentNode, "focus", true); info("Clicking on editable field to turn to edit mode"); EventUtils.synthesizeMouse(editable, xOffset, yOffset, options, @@ -428,9 +467,10 @@ let focusEditableField = Task.async(function*(ruleView, editable, xOffset=1, yOf /** * Given a tooltip object instance (see Tooltip.js), checks if it is set to - * toggle and hover and if so, checks if the given target is a valid hover target. - * This won't actually show the tooltip (the less we interact with XUL panels - * during test runs, the better). + * toggle and hover and if so, checks if the given target is a valid hover + * target. This won't actually show the tooltip (the less we interact with XUL + * panels during test runs, the better). + * * @return a promise that resolves when the answer is known */ function isHoverTooltipTarget(tooltip, target) { @@ -444,6 +484,7 @@ function isHoverTooltipTarget(tooltip, target) { /** * Same as isHoverTooltipTarget except that it will fail the test if there is no * tooltip defined on hover of the given element + * * @return a promise */ function assertHoverTooltipOn(tooltip, element) { @@ -457,6 +498,7 @@ function assertHoverTooltipOn(tooltip, element) { /** * Same as assertHoverTooltipOn but fails the test if there is a tooltip defined * on hover of the given element + * * @return a promise */ function assertNoHoverTooltipOn(tooltip, element) { @@ -471,6 +513,7 @@ function assertNoHoverTooltipOn(tooltip, element) { * Listen for a new window to open and return a promise that resolves when one * does and completes its load. * Only resolves when the new window topic isn't domwindowopened. + * * @return a promise that resolves to the window object */ function waitForWindow() { @@ -496,6 +539,7 @@ function waitForWindow() { /** * Listen for a new tab to open and return a promise that resolves when one * does and completes the load event. + * * @return a promise that resolves to the tab object */ let waitForTab = Task.async(function*() { @@ -510,9 +554,12 @@ let waitForTab = Task.async(function*() { /** * @see SimpleTest.waitForClipboard - * @param {Function} setup Function to execute before checking for the - * clipboard content - * @param {String|Boolean} expected An expected string or validator function + * + * @param {Function} setup + * Function to execute before checking for the + * clipboard content + * @param {String|Boolean} expected + * An expected string or validator function * @return a promise that resolves when the expected string has been found or * the validator function has returned true, rejects otherwise. */ @@ -534,23 +581,25 @@ function fireCopyEvent(element) { /** * Polls a given function waiting for it to return true. * - * @param {Function} validatorFn A validator function that returns a boolean. - * This is called every few milliseconds to check if the result is true. When - * it is true, the promise resolves. - * @param {String} name Optional name of the test. This is used to generate - * the success and failure messages. + * @param {Function} validatorFn + * A validator function that returns a boolean. + * This is called every few milliseconds to check if the result is true. + * When it is true, the promise resolves. + * @param {String} name + * Optional name of the test. This is used to generate + * the success and failure messages. * @return a promise that resolves when the function returned true or rejects * if the timeout is reached */ function waitForSuccess(validatorFn, name="untitled") { let def = promise.defer(); - function wait(validatorFn) { - if (validatorFn()) { + function wait(validator) { + if (validator()) { ok(true, "Validator function " + name + " returned true"); def.resolve(); } else { - setTimeout(() => wait(validatorFn), 200); + setTimeout(() => wait(validator), 200); } } wait(validatorFn); @@ -561,6 +610,7 @@ function waitForSuccess(validatorFn, name="untitled") { /** * Create a new style tag containing the given style text and append it to the * document's head node + * * @param {Document} doc * @param {String} style * @return {DOMNode} The newly created style node @@ -568,7 +618,7 @@ function waitForSuccess(validatorFn, name="untitled") { function addStyle(doc, style) { info("Adding a new style tag to the document with style content: " + style.substring(0, 50)); - let node = doc.createElement('style'); + let node = doc.createElement("style"); node.setAttribute("type", "text/css"); node.textContent = style; doc.getElementsByTagName("head")[0].appendChild(node); @@ -578,6 +628,7 @@ function addStyle(doc, style) { /** * Checks whether the inspector's sidebar corresponding to the given id already * exists + * * @param {InspectorPanel} * @param {String} * @return {Boolean} @@ -588,7 +639,9 @@ function hasSideBarTab(inspector, id) { /** * Get the dataURL for the font family tooltip. - * @param {String} font The font family value. + * + * @param {String} font + * The font family value. * @param {object} nodeFront * The NodeActor that will used to retrieve the dataURL for the * font family tooltip contents. @@ -604,12 +657,15 @@ let getFontFamilyDataURL = Task.async(function*(font, nodeFront) { /** * Simulate the key input for the given input in the window. - * @param {String} input The string value to input - * @param {Window} win The window containing the panel + * + * @param {String} input + * The string value to input + * @param {Window} win + * The window containing the panel */ function synthesizeKeys(input, win) { for (let key of input.split("")) { - EventUtils.synthesizeKey(key, {}, win); + EventUtils.synthesizeKey(key, {}, win); } } @@ -623,9 +679,12 @@ function synthesizeKeys(input, win) { /** * Get the DOMNode for a css rule in the rule-view that corresponds to the given * selector - * @param {CssRuleView} view The instance of the rule-view panel - * @param {String} selectorText The selector in the rule-view for which the rule - * object is wanted + * + * @param {CssRuleView} view + * The instance of the rule-view panel + * @param {String} selectorText + * The selector in the rule-view for which the rule + * object is wanted * @return {DOMNode} */ function getRuleViewRule(view, selectorText) { @@ -645,10 +704,13 @@ function getRuleViewRule(view, selectorText) { /** * Get references to the name and value span nodes corresponding to a given * selector and property name in the rule-view - * @param {CssRuleView} view The instance of the rule-view panel - * @param {String} selectorText The selector in the rule-view to look for the - * property in - * @param {String} propertyName The name of the property + * + * @param {CssRuleView} view + * The instance of the rule-view panel + * @param {String} selectorText + * The selector in the rule-view to look for the property in + * @param {String} propertyName + * The name of the property * @return {Object} An object like {nameSpan: DOMNode, valueSpan: DOMNode} */ function getRuleViewProperty(view, selectorText, propertyName) { @@ -673,10 +735,13 @@ function getRuleViewProperty(view, selectorText, propertyName) { /** * Get the text value of the property corresponding to a given selector and name * in the rule-view - * @param {CssRuleView} view The instance of the rule-view panel - * @param {String} selectorText The selector in the rule-view to look for the - * property in - * @param {String} propertyName The name of the property + * + * @param {CssRuleView} view + * The instance of the rule-view panel + * @param {String} selectorText + * The selector in the rule-view to look for the property in + * @param {String} propertyName + * The name of the property * @return {String} The property value */ function getRuleViewPropertyValue(view, selectorText, propertyName) { @@ -687,8 +752,11 @@ function getRuleViewPropertyValue(view, selectorText, propertyName) { /** * Get a reference to the selector DOM element corresponding to a given selector * in the rule-view - * @param {CssRuleView} view The instance of the rule-view panel - * @param {String} selectorText The selector in the rule-view to look for + * + * @param {CssRuleView} view + * The instance of the rule-view panel + * @param {String} selectorText + * The selector in the rule-view to look for * @return {DOMNode} The selector DOM element */ function getRuleViewSelector(view, selectorText) { @@ -699,8 +767,11 @@ function getRuleViewSelector(view, selectorText) { /** * Get a reference to the selectorhighlighter icon DOM element corresponding to * a given selector in the rule-view - * @param {CssRuleView} view The instance of the rule-view panel - * @param {String} selectorText The selector in the rule-view to look for + * + * @param {CssRuleView} view + * The instance of the rule-view panel + * @param {String} selectorText + * The selector in the rule-view to look for * @return {DOMNode} The selectorhighlighter icon DOM element */ function getRuleViewSelectorHighlighterIcon(view, selectorText) { @@ -711,17 +782,22 @@ function getRuleViewSelectorHighlighterIcon(view, selectorText) { /** * Simulate a color change in a given color picker tooltip, and optionally wait * for a given element in the page to have its style changed as a result - * @param {RuleView} ruleView The related rule view instance + * + * @param {RuleView} ruleView + * The related rule view instance * @param {SwatchColorPickerTooltip} colorPicker - * @param {Array} newRgba The new color to be set [r, g, b, a] - * @param {Object} expectedChange Optional object that needs the following props: - * - {DOMNode} element The element in the page that will have its - * style changed. - * - {String} name The style name that will be changed - * - {String} value The expected style value + * @param {Array} newRgba + * The new color to be set [r, g, b, a] + * @param {Object} expectedChange + * Optional object that needs the following props: + * - {DOMNode} element The element in the page that will have its + * style changed. + * - {String} name The style name that will be changed + * - {String} value The expected style value * The style will be checked like so: getComputedStyle(element)[name] === value */ -let simulateColorPickerChange = Task.async(function*(ruleView, colorPicker, newRgba, expectedChange) { +let simulateColorPickerChange = Task.async(function*(ruleView, colorPicker, + newRgba, expectedChange) { let onRuleViewChanged = ruleView.once("ruleview-changed"); info("Getting the spectrum colorpicker object"); let spectrum = yield colorPicker.spectrum; @@ -744,8 +820,11 @@ let simulateColorPickerChange = Task.async(function*(ruleView, colorPicker, newR /** * Get a rule-link from the rule-view given its index - * @param {CssRuleView} view The instance of the rule-view panel - * @param {Number} index The index of the link to get + * + * @param {CssRuleView} view + * The instance of the rule-view panel + * @param {Number} index + * The index of the link to get * @return {DOMNode} The link if any at this index */ function getRuleViewLinkByIndex(view, index) { @@ -755,8 +834,11 @@ function getRuleViewLinkByIndex(view, index) { /** * Get rule-link text from the rule-view given its index - * @param {CssRuleView} view The instance of the rule-view panel - * @param {Number} index The index of the link to get + * + * @param {CssRuleView} view + * The instance of the rule-view panel + * @param {Number} index + * The index of the link to get * @return {String} The string at this index */ function getRuleViewLinkTextByIndex(view, index) { @@ -766,9 +848,13 @@ function getRuleViewLinkTextByIndex(view, index) { /** * Get the rule editor from the rule-view given its index - * @param {CssRuleView} view The instance of the rule-view panel - * @param {Number} childrenIndex The children index of the element to get - * @param {Number} nodeIndex The child node index of the element to get + * + * @param {CssRuleView} view + * The instance of the rule-view panel + * @param {Number} childrenIndex + * The children index of the element to get + * @param {Number} nodeIndex + * The child node index of the element to get * @return {DOMNode} The rule editor if any at this index */ function getRuleViewRuleEditor(view, childrenIndex, nodeIndex) { @@ -779,8 +865,9 @@ function getRuleViewRuleEditor(view, childrenIndex, nodeIndex) { /** * Click on a rule-view's close brace to focus a new property name editor - * @param {RuleEditor} ruleEditor An instance of RuleEditor that will receive - * the new property + * + * @param {RuleEditor} ruleEditor + * An instance of RuleEditor that will receive the new property * @return a promise that resolves to the newly created editor when ready and * focused */ @@ -801,10 +888,11 @@ let focusNewRuleViewProperty = Task.async(function*(ruleEditor) { * by clicking on the close brace, and then entering the given text. * Keep in mind that the rule-view knows how to handle strings with multiple * properties, so the input text may be like: "p1:v1;p2:v2;p3:v3". - * @param {RuleEditor} ruleEditor The instance of RuleEditor that will receive - * the new property(ies) - * @param {String} inputValue The text to be entered in the new property name - * field + * + * @param {RuleEditor} ruleEditor + * The instance of RuleEditor that will receive the new property(ies) + * @param {String} inputValue + * The text to be entered in the new property name field * @return a promise that resolves when the new property name has been entered * and once the value field is focused */ @@ -832,8 +920,11 @@ let createNewRuleViewProperty = Task.async(function*(ruleEditor, inputValue) { /** * Get references to the name and value span nodes corresponding to a given * property name in the computed-view - * @param {CssComputedView} view The instance of the computed view panel - * @param {String} name The name of the property to retrieve + * + * @param {CssComputedView} view + * The instance of the computed view panel + * @param {String} name + * The name of the property to retrieve * @return an object {nameSpan, valueSpan} */ function getComputedViewProperty(view, name) { @@ -852,8 +943,11 @@ function getComputedViewProperty(view, name) { /** * Get an instance of PropertyView from the computed-view. - * @param {CssComputedView} view The instance of the computed view panel - * @param {String} name The name of the property to retrieve + * + * @param {CssComputedView} view + * The instance of the computed view panel + * @param {String} name + * The name of the property to retrieve * @return {PropertyView} */ function getComputedViewPropertyView(view, name) { @@ -872,10 +966,13 @@ function getComputedViewPropertyView(view, name) { * the computed-view. * A property-content element always follows (nextSibling) the property itself * and is only shown when the twisty icon is expanded on the property. - * A property-content element contains matched rules, with selectors, properties, - * values and stylesheet links - * @param {CssComputedView} view The instance of the computed view panel - * @param {String} name The name of the property to retrieve + * A property-content element contains matched rules, with selectors, + * properties, values and stylesheet links + * + * @param {CssComputedView} view + * The instance of the computed view panel + * @param {String} name + * The name of the property to retrieve * @return {Promise} A promise that resolves to the property matched rules * container */ @@ -904,8 +1001,11 @@ let getComputedViewMatchedRules = Task.async(function*(view, name) { /** * Get the text value of the property corresponding to a given name in the * computed-view - * @param {CssComputedView} view The instance of the computed view panel - * @param {String} name The name of the property to retrieve + * + * @param {CssComputedView} view + * The instance of the computed view panel + * @param {String} name + * The name of the property to retrieve * @return {String} The property value */ function getComputedViewPropertyValue(view, name, propertyName) { @@ -916,8 +1016,11 @@ function getComputedViewPropertyValue(view, name, propertyName) { /** * Expand a given property, given its index in the current property list of * the computed view - * @param {CssComputedView} view The instance of the computed view panel - * @param {Number} index The index of the property to be expanded + * + * @param {CssComputedView} view + * The instance of the computed view panel + * @param {Number} index + * The index of the property to be expanded * @return a promise that resolves when the property has been expanded, or * rejects if the property was not found */ @@ -935,8 +1038,11 @@ function expandComputedViewPropertyByIndex(view, index) { /** * Get a rule-link from the computed-view given its index - * @param {CssComputedView} view The instance of the computed view panel - * @param {Number} index The index of the link to be retrieved + * + * @param {CssComputedView} view + * The instance of the computed view panel + * @param {Number} index + * The index of the link to be retrieved * @return {DOMNode} The link at the given index, if one exists, null otherwise */ function getComputedViewLinkByIndex(view, index) { @@ -954,9 +1060,10 @@ function getComputedViewLinkByIndex(view, index) { * Wait for the toolbox to emit the styleeditor-selected event and when done * wait for the stylesheet identified by href to be loaded in the stylesheet * editor + * * @param {Toolbox} toolbox - * @param {String} href Optional, if not provided, wait for the first editor - * to be ready + * @param {String} href + * Optional, if not provided, wait for the first editor to be ready * @return a promise that resolves to the editor when the stylesheet editor is * ready */ @@ -976,9 +1083,9 @@ function waitForStyleEditor(toolbox, href) { info("Stylesheet editor selected"); panel.UI.off("editor-selected", gotEditor); - editor.getSourceEditor().then(editor => { + editor.getSourceEditor().then(sourceEditor => { info("Stylesheet editor fully loaded"); - def.resolve(editor); + def.resolve(sourceEditor); }); return true; @@ -1003,9 +1110,11 @@ function waitForStyleEditor(toolbox, href) { /** * Reload the current page and wait for the inspector to be initialized after * the navigation + * * @param {InspectorPanel} inspector * The instance of InspectorPanel currently loaded in the toolbox - * @return a promise that resolves after page reload and inspector initialization + * @return a promise that resolves after page reload and inspector + * initialization */ function reloadPage(inspector) { let onNewRoot = inspector.once("new-root"); diff --git a/browser/devtools/styleinspector/test/unit/test_parseDeclarations.js b/browser/devtools/styleinspector/test/unit/test_parseDeclarations.js index c9916e4e5e26..a7779f46f660 100644 --- a/browser/devtools/styleinspector/test/unit/test_parseDeclarations.js +++ b/browser/devtools/styleinspector/test/unit/test_parseDeclarations.js @@ -3,9 +3,12 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + const Cu = Components.utils; const {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); -const {parseDeclarations} = require("devtools/styleinspector/css-parsing-utils"); +const {parseDeclarations} = + require("devtools/styleinspector/css-parsing-utils"); const TEST_DATA = [ // Simple test @@ -31,7 +34,8 @@ const TEST_DATA = [ input: "name:value", expected: [{name: "name", value: "value", priority: ""}] }, - // Test multiple declarations separated by whitespaces and carriage returns and tabs + // Test multiple declarations separated by whitespaces and carriage + // returns and tabs { input: "p1 : v1 ; \t\t \n p2:v2; \n\n\n\n\t p3 : v3;", expected: [ @@ -74,22 +78,38 @@ const TEST_DATA = [ // Test various types of background-image urls { input: "background-image: url(../../relative/image.png)", - expected: [{name: "background-image", value: "url(../../relative/image.png)", priority: ""}] + expected: [{ + name: "background-image", + value: "url(../../relative/image.png)", + priority: "" + }] }, { input: "background-image: url(http://site.com/test.png)", - expected: [{name: "background-image", value: "url(http://site.com/test.png)", priority: ""}] + expected: [{ + name: "background-image", + value: "url(http://site.com/test.png)", + priority: "" + }] }, { input: "background-image: url(wow.gif)", - expected: [{name: "background-image", value: "url(wow.gif)", priority: ""}] + expected: [{ + name: "background-image", + value: "url(wow.gif)", + priority: "" + }] }, // Test that urls with :;{} characters in them are parsed correctly { - input: "background: red url(\"http://site.com/image{}:;.png?id=4#wat\") repeat top right", - expected: [ - {name: "background", value: "red url(\"http://site.com/image{}:;.png?id=4#wat\") repeat top right", priority: ""} - ] + input: "background: red url(\"http://site.com/image{}:;.png?id=4#wat\") " + + "repeat top right", + expected: [{ + name: "background", + value: "red url(\"http://site.com/image{}:;.png?id=4#wat\") " + + "repeat top right", + priority: "" + }] }, // Test that an empty string results in an empty array {input: "", expected: []}, @@ -99,12 +119,15 @@ const TEST_DATA = [ {input: null, throws: true}, // Test that a undefined input throws an exception {input: undefined, throws: true}, - // Test that :;{} characters in quoted content are not parsed as multiple declarations + // Test that :;{} characters in quoted content are not parsed as multiple + // declarations { input: "content: \";color:red;}selector{color:yellow;\"", - expected: [ - {name: "content", value: "\";color:red;}selector{color:yellow;\"", priority: ""} - ] + expected: [{ + name: "content", + value: "\";color:red;}selector{color:yellow;\"", + priority: "" + }] }, // Test that rules aren't parsed, just declarations. So { and } found after a // property name should be part of the property name, same for values. @@ -119,12 +142,18 @@ const TEST_DATA = [ // Test unbalanced : and ; { input: "color :red : font : arial;", - expected : [ + expected: [ {name: "color", value: "red : font : arial", priority: ""} ] }, - {input: "background: red;;;;;", expected: [{name: "background", value: "red", priority: ""}]}, - {input: "background:;", expected: [{name: "background", value: "", priority: ""}]}, + { + input: "background: red;;;;;", + expected: [{name: "background", value: "red", priority: ""}] + }, + { + input: "background:;", + expected: [{name: "background", value: "", priority: ""}] + }, {input: ";;;;;", expected: []}, {input: ":;:;", expected: []}, // Test name only @@ -147,15 +176,54 @@ const TEST_DATA = [ {name: "color", value: "blue", priority: ""} ]}, // Test hex colors - {input: "color: #333", expected: [{name: "color", value: "#333", priority: ""}]}, - {input: "color: #456789", expected: [{name: "color", value: "#456789", priority: ""}]}, - {input: "wat: #XYZ", expected: [{name: "wat", value: "#XYZ", priority: ""}]}, + { + input: "color: #333", + expected: [{name: "color", value: "#333", priority: ""}] + }, + { + input: "color: #456789", + expected: [{name: "color", value: "#456789", priority: ""}] + }, + { + input: "wat: #XYZ", + expected: [{name: "wat", value: "#XYZ", priority: ""}] + }, // Test string/url quotes escaping - {input: "content: \"this is a 'string'\"", expected: [{name: "content", value: "\"this is a 'string'\"", priority: ""}]}, - {input: 'content: "this is a \\"string\\""', expected: [{name: "content", value: '"this is a \\"string\\""', priority: ""}]}, - {input: "content: 'this is a \"string\"'", expected: [{name: "content", value: '\'this is a "string"\'', priority: ""}]}, - {input: "content: 'this is a \\'string\\''", expected: [{name: "content", value: "'this is a \\'string\\''", priority: ""}]}, - {input: "content: 'this \\' is a \" really strange string'", expected: [{name: "content", value: "'this \\' is a \" really strange string'", priority: ""}]}, + { + input: "content: \"this is a 'string'\"", + expected: [{name: "content", value: "\"this is a 'string'\"", priority: ""}] + }, + { + input: 'content: "this is a \\"string\\""', + expected: [{ + name: "content", + value: '"this is a \\"string\\""', + priority: ""}] + }, + { + input: "content: 'this is a \"string\"'", + expected: [{ + name: "content", + value: '\'this is a "string"\'', + priority: "" + }] + }, + { + input: "content: 'this is a \\'string\\''", + expected: [{ + name: "content", + value: "'this is a \\'string\\''", + priority: "" + }] + }, + { + input: "content: 'this \\' is a \" really strange string'", + expected: [{ + name: "content", + value: "'this \\' is a \" really strange string'", + priority: "" + }] + }, { input: "content: \"a not s\\\ o very long title\"", @@ -165,7 +233,10 @@ const TEST_DATA = [ ] }, // Test calc with nested parentheses - {input: "width: calc((100% - 3em) / 2)", expected: [{name: "width", value: "calc((100% - 3em) / 2)", priority: ""}]}, + { + input: "width: calc((100% - 3em) / 2)", + expected: [{name: "width", value: "calc((100% - 3em) / 2)", priority: ""}] + }, ]; function run_test() { @@ -175,7 +246,8 @@ function run_test() { try { output = parseDeclarations(test.input); } catch (e) { - do_print("parseDeclarations threw an exception with the given input string"); + do_print("parseDeclarations threw an exception with the given input " + + "string"); if (test.throws) { do_print("Exception expected"); do_check_true(true); @@ -192,16 +264,18 @@ function run_test() { function assertOutput(actual, expected) { if (actual.length === expected.length) { - for (let i = 0; i < expected.length; i ++) { + for (let i = 0; i < expected.length; i++) { do_check_true(!!actual[i]); - do_print("Check that the output item has the expected name, value and priority"); + do_print("Check that the output item has the expected name, " + + "value and priority"); do_check_eq(expected[i].name, actual[i].name); do_check_eq(expected[i].value, actual[i].value); do_check_eq(expected[i].priority, actual[i].priority); } } else { for (let prop of actual) { - do_print("Actual output contained: {name: "+prop.name+", value: "+prop.value+", priority: "+prop.priority+"}"); + do_print("Actual output contained: {name: " + prop.name + ", value: " + + prop.value + ", priority: " + prop.priority + "}"); } do_check_eq(actual.length, expected.length); } diff --git a/browser/devtools/styleinspector/test/unit/test_parseSingleValue.js b/browser/devtools/styleinspector/test/unit/test_parseSingleValue.js index 433be0a8e950..39d3409c4167 100644 --- a/browser/devtools/styleinspector/test/unit/test_parseSingleValue.js +++ b/browser/devtools/styleinspector/test/unit/test_parseSingleValue.js @@ -3,6 +3,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + const Cu = Components.utils; const {require} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); const {parseSingleValue} = require("devtools/styleinspector/css-parsing-utils"); @@ -16,10 +18,16 @@ const TEST_DATA = [ {input: "blue !important", expected: {value: "blue", priority: "important"}}, {input: "blue!important", expected: {value: "blue", priority: "important"}}, {input: "blue ! important", expected: {value: "blue", priority: "important"}}, - {input: "blue ! important", expected: {value: "blue", priority: "important"}}, + { + input: "blue ! important", + expected: {value: "blue", priority: "important"} + }, {input: "blue !", expected: {value: "blue", priority: ""}}, {input: "blue !mportant", expected: {value: "blue !mportant", priority: ""}}, - {input: " blue !important ", expected: {value: "blue", priority: "important"}}, + { + input: " blue !important ", + expected: {value: "blue", priority: "important"} + }, { input: "url(\"http://url.com/whyWouldYouDoThat!important.png\") !important", expected: { @@ -64,7 +72,8 @@ function run_test() { let output = parseSingleValue(test.input); assertOutput(output, test.expected); } catch (e) { - do_print("parseSingleValue threw an exception with the given input value"); + do_print("parseSingleValue threw an exception with the given input " + + "value"); if (test.throws) { do_print("Exception expected"); do_check_true(true); diff --git a/browser/devtools/tilt/test/browser_tilt_picking_inspector.js b/browser/devtools/tilt/test/browser_tilt_picking_inspector.js index 5b625e8f4d14..709f9866af97 100644 --- a/browser/devtools/tilt/test/browser_tilt_picking_inspector.js +++ b/browser/devtools/tilt/test/browser_tilt_picking_inspector.js @@ -2,7 +2,8 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; -let presenter; +Components.utils.import("resource://gre/modules/Task.jsm"); +let promise = require("promise"); function test() { if (!isTiltEnabled()) { @@ -22,27 +23,39 @@ function test() { let {TargetFactory} = require("devtools/framework/target"); let target = TargetFactory.forTab(gBrowser.selectedTab); - gDevTools.showToolbox(target, "inspector").then(function(toolbox) { - let contentDocument = toolbox.target.tab.linkedBrowser.contentDocument; - let div = contentDocument.getElementById("first-law"); - toolbox.getCurrentPanel().selection.setNode(div); - - createTilt({ - onTiltOpen: function(instance) - { - presenter = instance.presenter; - whenOpen(); - } - }, false, function suddenDeath() - { - ok(false, "Tilt could not be initialized properly."); - cleanup(); - }); - }); + gDevTools.showToolbox(target, "inspector") + .then(Task.async(onToolbox)); }); } -function whenOpen() { +function* onToolbox(toolbox) { + let contentDocument = toolbox.target.tab.linkedBrowser.contentDocument; + let div = contentDocument.getElementById("first-law"); + let inspector = toolbox.getPanel("inspector"); + + let onInspectorUpdated = inspector.once("inspector-updated"); + inspector.selection.setNode(div); + yield onInspectorUpdated; + + let deferred = promise.defer(); + onInspectorUpdated = inspector.once("inspector-updated"); + createTilt({ + onTiltOpen: function(instance) + { + deferred.resolve(instance.presenter); + } + }, false, function suddenDeath() + { + ok(false, "Tilt could not be initialized properly."); + cleanup(); + }); + let presenter = yield deferred.promise; + yield onInspectorUpdated; + + whenOpen(presenter); +} + +function whenOpen(presenter) { ok(presenter._currentSelection > 0, "Highlighting a node didn't work properly."); ok(!presenter._highlight.disabled, diff --git a/browser/devtools/webconsole/test/browser_webconsole_output_05.js b/browser/devtools/webconsole/test/browser_webconsole_output_05.js index 8e754bb883c0..bcf3e82335ac 100644 --- a/browser/devtools/webconsole/test/browser_webconsole_output_05.js +++ b/browser/devtools/webconsole/test/browser_webconsole_output_05.js @@ -11,7 +11,14 @@ const TEST_URI = "data:text/html;charset=utf8,test for console output - 05"; const ELLIPSIS = Services.prefs.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data; -let dateNow = Date.now(); +// March, 1960: The first implementation of Lisp. From Wikipedia: +// +// > Lisp was first implemented by Steve Russell on an IBM 704 computer. Russell +// > had read McCarthy's paper, and realized (to McCarthy's surprise) that the +// > Lisp eval function could be implemented in machine code. The result was a +// > working Lisp interpreter which could be used to run Lisp programs, or more +// > properly, 'evaluate Lisp expressions.' +let testDate = -310435200000; let inputTests = [ // 0 @@ -49,9 +56,9 @@ let inputTests = [ // 5 { - input: "new Date(" + dateNow + ")", - output: "Date " + (new Date(dateNow)).toISOString(), - printOutput: (new Date(dateNow)).toString(), + input: "new Date(" + testDate + ")", + output: "Date " + (new Date(testDate)).toISOString(), + printOutput: (new Date(testDate)).toString(), inspectable: true, }, @@ -132,6 +139,6 @@ function test() { } function finishUp() { - inputTests = dateNow = null; + inputTests = testDate = null; finishTest(); } diff --git a/browser/locales/en-US/chrome/browser/loop/loop.properties b/browser/locales/en-US/chrome/browser/loop/loop.properties index 3dd4f1a176da..4b1f9c23f4c6 100644 --- a/browser/locales/en-US/chrome/browser/loop/loop.properties +++ b/browser/locales/en-US/chrome/browser/loop/loop.properties @@ -91,13 +91,13 @@ contacts_search_placesholder=Search… ## LOCALIZATION NOTE (new_contact_button): This is the button to open the ## new contact sub-panel. new_contact_button=New Contact -## LOCALIZATION NOTE (new_contact_name_placeholder, new_contact_email_placeholder): -## These are the placeholders for the fields for entering a new contact. Click -## the 'New Contact' button to see the fields. -new_contact_name_placeholder=Name -new_contact_email_placeholder=Email -new_contact_fxos_phone_placeholder=Firefox OS Phone -new_contact_phone_placeholder2=Phone +## LOCALIZATION NOTE (contact_form_*_placeholder): +## These are the placeholders for the inputs for entering or editing a contact +## Click the 'New Contact' button to see the fields. +contact_form_name_placeholder=Name +contact_form_email_placeholder=Email +contact_form_fxos_phone_placeholder=Firefox OS Phone +contact_form_phone_placeholder2=Phone contacts_blocked_contacts=Blocked Contacts @@ -105,6 +105,9 @@ contacts_blocked_contacts=Blocked Contacts ## This is the button to actually add the new contact. Click the 'New Contact' ## button to see the fields. add_contact_button=Add Contact +## LOCALIZATION NOTE(add_contact_title): This is the subtitle of the add contact +## panel. It is displayed when Add Contact is selected. +add_contact_title=Add Contact ### LOCALIZATION NOTE (valid_email_text_description): This is displayed when ### the user enters an invalid email address, preventing the addition of the ### contact. diff --git a/media/webrtc/trunk/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/AudioManagerAndroid.java b/media/webrtc/trunk/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/AudioManagerAndroid.java index 5067b7c87b95..c80207e28afd 100644 --- a/media/webrtc/trunk/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/AudioManagerAndroid.java +++ b/media/webrtc/trunk/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/AudioManagerAndroid.java @@ -21,7 +21,7 @@ import android.util.Log; import java.lang.reflect.Field; import java.lang.reflect.Method; -import org.mozilla.gecko.mozglue.WebRTCJNITarget; +import org.mozilla.gecko.annotation.WebRTCJNITarget; @WebRTCJNITarget class AudioManagerAndroid { diff --git a/media/webrtc/trunk/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java b/media/webrtc/trunk/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java index ef8b976f119d..7a9267e21e02 100644 --- a/media/webrtc/trunk/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java +++ b/media/webrtc/trunk/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java @@ -20,7 +20,7 @@ import android.media.AudioRecord; import android.media.MediaRecorder.AudioSource; import android.util.Log; -import org.mozilla.gecko.mozglue.WebRTCJNITarget; +import org.mozilla.gecko.annotation.WebRTCJNITarget; @WebRTCJNITarget class WebRtcAudioRecord { diff --git a/media/webrtc/trunk/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java b/media/webrtc/trunk/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java index f525d97672e8..f131edc7f563 100644 --- a/media/webrtc/trunk/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java +++ b/media/webrtc/trunk/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java @@ -20,7 +20,7 @@ import android.media.AudioRecord; import android.media.AudioTrack; import android.util.Log; -import org.mozilla.gecko.mozglue.WebRTCJNITarget; +import org.mozilla.gecko.annotation.WebRTCJNITarget; @WebRTCJNITarget class WebRtcAudioTrack { diff --git a/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/CaptureCapabilityAndroid.java b/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/CaptureCapabilityAndroid.java index 6cefced35a6c..811be9d11a7a 100644 --- a/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/CaptureCapabilityAndroid.java +++ b/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/CaptureCapabilityAndroid.java @@ -10,7 +10,7 @@ package org.webrtc.videoengine; -import org.mozilla.gecko.mozglue.WebRTCJNITarget; +import org.mozilla.gecko.annotation.WebRTCJNITarget; @WebRTCJNITarget public class CaptureCapabilityAndroid { diff --git a/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java b/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java index c7729c4794a7..49290f5d7f2b 100644 --- a/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java +++ b/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java @@ -32,9 +32,9 @@ import android.view.SurfaceHolder.Callback; import android.view.SurfaceHolder; import android.view.WindowManager; +import org.mozilla.gecko.annotation.WebRTCJNITarget; import org.mozilla.gecko.GeckoAppShell; import org.mozilla.gecko.GeckoAppShell.AppStateListener; -import org.mozilla.gecko.mozglue.WebRTCJNITarget; // Wrapper for android Camera, with support for direct local preview rendering. // Threading notes: this class is called from ViE C++ code, and from Camera & diff --git a/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureDeviceInfoAndroid.java b/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureDeviceInfoAndroid.java index 082f0fdde81a..fed4e072c293 100644 --- a/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureDeviceInfoAndroid.java +++ b/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureDeviceInfoAndroid.java @@ -19,7 +19,7 @@ import android.hardware.Camera.Size; import android.hardware.Camera; import android.util.Log; -import org.mozilla.gecko.mozglue.WebRTCJNITarget; +import org.mozilla.gecko.annotation.WebRTCJNITarget; public class VideoCaptureDeviceInfoAndroid { private final static String TAG = "WEBRTC-JC"; diff --git a/media/webrtc/trunk/webrtc/modules/video_render/android/java/src/org/webrtc/videoengine/ViEAndroidGLES20.java b/media/webrtc/trunk/webrtc/modules/video_render/android/java/src/org/webrtc/videoengine/ViEAndroidGLES20.java index 788c71016db9..b1097504a285 100644 --- a/media/webrtc/trunk/webrtc/modules/video_render/android/java/src/org/webrtc/videoengine/ViEAndroidGLES20.java +++ b/media/webrtc/trunk/webrtc/modules/video_render/android/java/src/org/webrtc/videoengine/ViEAndroidGLES20.java @@ -25,7 +25,7 @@ import android.graphics.PixelFormat; import android.opengl.GLSurfaceView; import android.util.Log; -import org.mozilla.gecko.mozglue.WebRTCJNITarget; +import org.mozilla.gecko.annotation.WebRTCJNITarget; public class ViEAndroidGLES20 extends GLSurfaceView implements GLSurfaceView.Renderer { diff --git a/media/webrtc/trunk/webrtc/modules/video_render/android/java/src/org/webrtc/videoengine/ViESurfaceRenderer.java b/media/webrtc/trunk/webrtc/modules/video_render/android/java/src/org/webrtc/videoengine/ViESurfaceRenderer.java index 11fcd3da5c43..9f46255bfb16 100644 --- a/media/webrtc/trunk/webrtc/modules/video_render/android/java/src/org/webrtc/videoengine/ViESurfaceRenderer.java +++ b/media/webrtc/trunk/webrtc/modules/video_render/android/java/src/org/webrtc/videoengine/ViESurfaceRenderer.java @@ -26,7 +26,7 @@ import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.SurfaceHolder.Callback; -import org.mozilla.gecko.mozglue.WebRTCJNITarget; +import org.mozilla.gecko.annotation.WebRTCJNITarget; public class ViESurfaceRenderer implements Callback { diff --git a/mobile/android/base/AboutPages.java b/mobile/android/base/AboutPages.java index ada8e644abea..7f5574d66bce 100644 --- a/mobile/android/base/AboutPages.java +++ b/mobile/android/base/AboutPages.java @@ -5,9 +5,9 @@ package org.mozilla.gecko; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.home.HomeConfig; import org.mozilla.gecko.home.HomeConfig.PanelType; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.util.StringUtils; public class AboutPages { diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index a4ffe14ed57d..18746e186a63 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -5,6 +5,7 @@ package org.mozilla.gecko; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.AppConstants.Versions; import org.mozilla.gecko.DynamicToolbar.PinReason; import org.mozilla.gecko.DynamicToolbar.VisibilityTransition; @@ -49,7 +50,6 @@ import org.mozilla.gecko.menu.GeckoMenu; import org.mozilla.gecko.menu.GeckoMenuItem; import org.mozilla.gecko.mozglue.ContextUtils; import org.mozilla.gecko.mozglue.ContextUtils.SafeIntent; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.overlays.ui.ShareDialog; import org.mozilla.gecko.preferences.ClearOnShutdownPref; import org.mozilla.gecko.preferences.GeckoPreferences; diff --git a/mobile/android/base/CustomEditText.java b/mobile/android/base/CustomEditText.java index 2ea7d6d02ff9..23f8af545853 100644 --- a/mobile/android/base/CustomEditText.java +++ b/mobile/android/base/CustomEditText.java @@ -5,6 +5,7 @@ package org.mozilla.gecko; +import org.mozilla.gecko.util.ColorUtils; import org.mozilla.gecko.widget.ThemedEditText; import android.content.Context; @@ -80,7 +81,7 @@ public class CustomEditText extends ThemedEditText { public void setPrivateMode(boolean isPrivate) { super.setPrivateMode(isPrivate); - mHighlightColor = getContext().getResources().getColor(isPrivate + mHighlightColor = ColorUtils.getColor(getContext(), isPrivate ? R.color.url_bar_text_highlight_pb : R.color.fennec_ui_orange); // android:textColorHighlight cannot support a ColorStateList. setHighlightColor(mHighlightColor); diff --git a/mobile/android/base/EventDispatcher.java b/mobile/android/base/EventDispatcher.java index 6ec8cbb5f80c..30008230fbbc 100644 --- a/mobile/android/base/EventDispatcher.java +++ b/mobile/android/base/EventDispatcher.java @@ -4,9 +4,9 @@ package org.mozilla.gecko; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.GeckoAppShell; import org.mozilla.gecko.GeckoEvent; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.util.EventCallback; import org.mozilla.gecko.util.GeckoEventListener; import org.mozilla.gecko.util.NativeEventListener; diff --git a/mobile/android/base/GeckoAppShell.java b/mobile/android/base/GeckoAppShell.java index 70ef3ef16fad..d1a615bb47f3 100644 --- a/mobile/android/base/GeckoAppShell.java +++ b/mobile/android/base/GeckoAppShell.java @@ -30,6 +30,8 @@ import java.util.StringTokenizer; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; +import org.mozilla.gecko.annotation.JNITarget; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.annotation.WrapForJNI; import org.mozilla.gecko.AppConstants.Versions; import org.mozilla.gecko.db.BrowserDB; @@ -40,8 +42,6 @@ import org.mozilla.gecko.gfx.LayerView; import org.mozilla.gecko.gfx.PanZoomController; import org.mozilla.gecko.mozglue.ContextUtils; import org.mozilla.gecko.mozglue.GeckoLoader; -import org.mozilla.gecko.mozglue.JNITarget; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.overlays.ui.ShareDialog; import org.mozilla.gecko.prompts.PromptService; import org.mozilla.gecko.util.EventCallback; diff --git a/mobile/android/base/GeckoEvent.java b/mobile/android/base/GeckoEvent.java index c970aa7a39ed..0b3e1596439e 100644 --- a/mobile/android/base/GeckoEvent.java +++ b/mobile/android/base/GeckoEvent.java @@ -25,8 +25,8 @@ import android.util.Log; import android.util.SparseArray; import android.view.KeyEvent; import android.view.MotionEvent; -import org.mozilla.gecko.mozglue.JNITarget; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.JNITarget; +import org.mozilla.gecko.annotation.RobocopTarget; /** * We're not allowed to hold on to most events given to us diff --git a/mobile/android/base/GeckoNetworkManager.java b/mobile/android/base/GeckoNetworkManager.java index 0d349376fd2b..aaa2392fcc97 100644 --- a/mobile/android/base/GeckoNetworkManager.java +++ b/mobile/android/base/GeckoNetworkManager.java @@ -5,7 +5,7 @@ package org.mozilla.gecko; -import org.mozilla.gecko.mozglue.JNITarget; +import org.mozilla.gecko.annotation.JNITarget; import org.mozilla.gecko.util.NativeEventListener; import org.mozilla.gecko.util.NativeJSObject; import org.mozilla.gecko.util.EventCallback; diff --git a/mobile/android/base/GeckoProfile.java b/mobile/android/base/GeckoProfile.java index ae7d493cf4e1..134b5cbaa639 100644 --- a/mobile/android/base/GeckoProfile.java +++ b/mobile/android/base/GeckoProfile.java @@ -21,6 +21,7 @@ import java.util.regex.Pattern; import org.json.JSONException; import org.json.JSONArray; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.GeckoProfileDirectories.NoMozillaDirectoryException; import org.mozilla.gecko.GeckoProfileDirectories.NoSuchProfileException; import org.mozilla.gecko.db.BrowserDB; @@ -28,7 +29,6 @@ import org.mozilla.gecko.db.LocalBrowserDB; import org.mozilla.gecko.db.StubBrowserDB; import org.mozilla.gecko.distribution.Distribution; import org.mozilla.gecko.mozglue.ContextUtils; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.firstrun.FirstrunPane; import org.mozilla.gecko.RestrictedProfiles; import org.mozilla.gecko.util.INIParser; diff --git a/mobile/android/base/GeckoProfileDirectories.java b/mobile/android/base/GeckoProfileDirectories.java index d655928dacd2..f584c4ccfa0e 100644 --- a/mobile/android/base/GeckoProfileDirectories.java +++ b/mobile/android/base/GeckoProfileDirectories.java @@ -9,7 +9,7 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.Map; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.util.INIParser; import org.mozilla.gecko.util.INISection; diff --git a/mobile/android/base/GeckoSharedPrefs.java b/mobile/android/base/GeckoSharedPrefs.java index 7a64dd31e936..b4468bcacd20 100644 --- a/mobile/android/base/GeckoSharedPrefs.java +++ b/mobile/android/base/GeckoSharedPrefs.java @@ -9,7 +9,7 @@ import java.util.EnumSet; import java.util.List; import java.util.Map; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; import android.content.Context; import android.content.SharedPreferences; diff --git a/mobile/android/base/GeckoThread.java b/mobile/android/base/GeckoThread.java index 0b5b2f508b07..213cc6db21b2 100644 --- a/mobile/android/base/GeckoThread.java +++ b/mobile/android/base/GeckoThread.java @@ -5,8 +5,8 @@ package org.mozilla.gecko; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.mozglue.GeckoLoader; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.util.GeckoEventListener; import org.mozilla.gecko.util.ThreadUtils; diff --git a/mobile/android/base/MediaPlayerManager.java b/mobile/android/base/MediaPlayerManager.java index 80ed0870566f..da0b88875304 100644 --- a/mobile/android/base/MediaPlayerManager.java +++ b/mobile/android/base/MediaPlayerManager.java @@ -16,8 +16,8 @@ import android.util.Log; import com.google.android.gms.cast.CastMediaControlIntent; import org.json.JSONObject; +import org.mozilla.gecko.annotation.JNITarget; import org.mozilla.gecko.AppConstants.Versions; -import org.mozilla.gecko.mozglue.JNITarget; import org.mozilla.gecko.util.EventCallback; import org.mozilla.gecko.util.NativeEventListener; import org.mozilla.gecko.util.NativeJSObject; diff --git a/mobile/android/base/NSSBridge.java b/mobile/android/base/NSSBridge.java index 83dc32d9f2f7..8d525b0ba663 100644 --- a/mobile/android/base/NSSBridge.java +++ b/mobile/android/base/NSSBridge.java @@ -7,7 +7,7 @@ package org.mozilla.gecko; import org.mozilla.gecko.mozglue.GeckoLoader; import android.content.Context; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; public class NSSBridge { private static final String LOGTAG = "NSSBridge"; diff --git a/mobile/android/base/PrivateTab.java b/mobile/android/base/PrivateTab.java index 3392588e08c7..114cc4343563 100644 --- a/mobile/android/base/PrivateTab.java +++ b/mobile/android/base/PrivateTab.java @@ -8,6 +8,7 @@ package org.mozilla.gecko; import android.content.Context; import org.mozilla.gecko.db.BrowserDB; +import org.mozilla.gecko.util.ColorUtils; public class PrivateTab extends Tab { public PrivateTab(Context context, int id, String url, boolean external, int parentId, String title) { @@ -15,7 +16,7 @@ public class PrivateTab extends Tab { // Init background to private_toolbar_grey to ensure flicker-free // private tab creation. Page loads will reset it to white as expected. - final int bgColor = context.getResources().getColor(R.color.tabs_tray_grey_pressed); + final int bgColor = ColorUtils.getColor(context, R.color.tabs_tray_grey_pressed); setBackgroundColor(bgColor); } diff --git a/mobile/android/base/ReadingListHelper.java b/mobile/android/base/ReadingListHelper.java index 44501a55e292..a768b252f922 100644 --- a/mobile/android/base/ReadingListHelper.java +++ b/mobile/android/base/ReadingListHelper.java @@ -6,11 +6,11 @@ package org.mozilla.gecko; import org.json.JSONException; import org.json.JSONObject; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.db.BrowserContract.ReadingListItems; import org.mozilla.gecko.db.BrowserDB; import org.mozilla.gecko.db.ReadingListAccessor; import org.mozilla.gecko.favicons.Favicons; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.util.EventCallback; import org.mozilla.gecko.util.NativeEventListener; import org.mozilla.gecko.util.NativeJSObject; diff --git a/mobile/android/base/RemoteTabsExpandableListAdapter.java b/mobile/android/base/RemoteTabsExpandableListAdapter.java index e87e34bebf69..b7e4de9d51f6 100644 --- a/mobile/android/base/RemoteTabsExpandableListAdapter.java +++ b/mobile/android/base/RemoteTabsExpandableListAdapter.java @@ -10,6 +10,7 @@ import android.text.format.DateUtils; import org.mozilla.gecko.db.RemoteClient; import org.mozilla.gecko.db.RemoteTab; import org.mozilla.gecko.home.TwoLinePageRow; +import org.mozilla.gecko.util.ColorUtils; import android.content.Context; import android.text.TextUtils; @@ -161,7 +162,7 @@ public class RemoteTabsExpandableListAdapter extends BaseExpandableListAdapter { // Now update the UI. holder.nameView.setText(client.name); - holder.nameView.setTextColor(context.getResources().getColor(textColorResId)); + holder.nameView.setTextColor(ColorUtils.getColor(context, textColorResId)); final long now = System.currentTimeMillis(); diff --git a/mobile/android/base/RestrictedProfiles.java b/mobile/android/base/RestrictedProfiles.java index d52e6f05963c..27ec658972fe 100644 --- a/mobile/android/base/RestrictedProfiles.java +++ b/mobile/android/base/RestrictedProfiles.java @@ -5,9 +5,9 @@ package org.mozilla.gecko; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.annotation.WrapForJNI; import org.mozilla.gecko.AppConstants.Versions; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.restrictions.DefaultConfiguration; import org.mozilla.gecko.restrictions.GuestProfileConfiguration; import org.mozilla.gecko.restrictions.RestrictedProfileConfiguration; diff --git a/mobile/android/base/SuggestClient.java b/mobile/android/base/SuggestClient.java index 439f63271a72..ebea3d43c983 100644 --- a/mobile/android/base/SuggestClient.java +++ b/mobile/android/base/SuggestClient.java @@ -13,7 +13,7 @@ import java.net.URLEncoder; import java.util.ArrayList; import org.json.JSONArray; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.util.HardwareUtils; import android.content.Context; diff --git a/mobile/android/base/Tab.java b/mobile/android/base/Tab.java index ce16e7690d83..051eeb921249 100644 --- a/mobile/android/base/Tab.java +++ b/mobile/android/base/Tab.java @@ -15,6 +15,7 @@ import java.util.regex.Pattern; import org.json.JSONException; import org.json.JSONObject; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.db.BrowserDB; import org.mozilla.gecko.db.URLMetadata; import org.mozilla.gecko.favicons.Favicons; @@ -23,7 +24,6 @@ import org.mozilla.gecko.favicons.OnFaviconLoadedListener; import org.mozilla.gecko.favicons.RemoteFavicon; import org.mozilla.gecko.gfx.BitmapUtils; import org.mozilla.gecko.gfx.Layer; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.toolbar.BrowserToolbar.TabEditingState; import org.mozilla.gecko.util.ThreadUtils; diff --git a/mobile/android/base/Tabs.java b/mobile/android/base/Tabs.java index f2c801cf4884..22c4774d7fed 100644 --- a/mobile/android/base/Tabs.java +++ b/mobile/android/base/Tabs.java @@ -14,13 +14,13 @@ import java.util.concurrent.atomic.AtomicInteger; import org.json.JSONException; import org.json.JSONObject; +import org.mozilla.gecko.annotation.JNITarget; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.AppConstants.Versions; import org.mozilla.gecko.db.BrowserDB; import org.mozilla.gecko.favicons.Favicons; import org.mozilla.gecko.fxa.FirefoxAccounts; import org.mozilla.gecko.mozglue.ContextUtils.SafeIntent; -import org.mozilla.gecko.mozglue.JNITarget; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.sync.setup.SyncAccounts; import org.mozilla.gecko.preferences.GeckoPreferences; import org.mozilla.gecko.util.GeckoEventListener; diff --git a/mobile/android/base/Telemetry.java b/mobile/android/base/Telemetry.java index bac613bcf965..1ec3c5a5cdcf 100644 --- a/mobile/android/base/Telemetry.java +++ b/mobile/android/base/Telemetry.java @@ -5,7 +5,7 @@ package org.mozilla.gecko; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.TelemetryContract.Event; import org.mozilla.gecko.TelemetryContract.Method; import org.mozilla.gecko.TelemetryContract.Reason; diff --git a/mobile/android/base/TelemetryContract.java b/mobile/android/base/TelemetryContract.java index 68d8b3d63578..97799a5bafd7 100644 --- a/mobile/android/base/TelemetryContract.java +++ b/mobile/android/base/TelemetryContract.java @@ -5,7 +5,7 @@ package org.mozilla.gecko; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; /** * Holds data definitions for our UI Telemetry implementation. diff --git a/mobile/android/base/mozglue/JNITarget.java b/mobile/android/base/annotation/JNITarget.java similarity index 93% rename from mobile/android/base/mozglue/JNITarget.java rename to mobile/android/base/annotation/JNITarget.java index 2cfd8496909f..d6140a1ffb66 100644 --- a/mobile/android/base/mozglue/JNITarget.java +++ b/mobile/android/base/annotation/JNITarget.java @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package org.mozilla.gecko.mozglue; +package org.mozilla.gecko.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/mobile/android/base/mozglue/RobocopTarget.java b/mobile/android/base/annotation/RobocopTarget.java similarity index 93% rename from mobile/android/base/mozglue/RobocopTarget.java rename to mobile/android/base/annotation/RobocopTarget.java index 94fa1b85fb09..e15130674801 100644 --- a/mobile/android/base/mozglue/RobocopTarget.java +++ b/mobile/android/base/annotation/RobocopTarget.java @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package org.mozilla.gecko.mozglue; +package org.mozilla.gecko.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/mobile/android/base/mozglue/WebRTCJNITarget.java b/mobile/android/base/annotation/WebRTCJNITarget.java similarity index 93% rename from mobile/android/base/mozglue/WebRTCJNITarget.java rename to mobile/android/base/annotation/WebRTCJNITarget.java index aad1cbfda29d..f58dea148764 100644 --- a/mobile/android/base/mozglue/WebRTCJNITarget.java +++ b/mobile/android/base/annotation/WebRTCJNITarget.java @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package org.mozilla.gecko.mozglue; +package org.mozilla.gecko.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/mobile/android/base/background/nativecode/NativeCrypto.java b/mobile/android/base/background/nativecode/NativeCrypto.java index a48c4862716c..d72db75cc6d9 100644 --- a/mobile/android/base/background/nativecode/NativeCrypto.java +++ b/mobile/android/base/background/nativecode/NativeCrypto.java @@ -6,8 +6,8 @@ package org.mozilla.gecko.background.nativecode; import java.security.GeneralSecurityException; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.AppConstants; -import org.mozilla.gecko.mozglue.RobocopTarget; import android.util.Log; diff --git a/mobile/android/base/db/AbstractPerProfileDatabaseProvider.java b/mobile/android/base/db/AbstractPerProfileDatabaseProvider.java index 832192765fb5..2e056cc1ea7c 100644 --- a/mobile/android/base/db/AbstractPerProfileDatabaseProvider.java +++ b/mobile/android/base/db/AbstractPerProfileDatabaseProvider.java @@ -4,7 +4,7 @@ package org.mozilla.gecko.db; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; diff --git a/mobile/android/base/db/BrowserContract.java b/mobile/android/base/db/BrowserContract.java index c662da594bf1..7cc275984123 100644 --- a/mobile/android/base/db/BrowserContract.java +++ b/mobile/android/base/db/BrowserContract.java @@ -8,7 +8,7 @@ package org.mozilla.gecko.db; import org.mozilla.gecko.AppConstants; import android.net.Uri; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; @RobocopTarget public class BrowserContract { diff --git a/mobile/android/base/db/DBUtils.java b/mobile/android/base/db/DBUtils.java index 3851eb9c9a38..608ada5a2452 100644 --- a/mobile/android/base/db/DBUtils.java +++ b/mobile/android/base/db/DBUtils.java @@ -19,8 +19,8 @@ import android.database.sqlite.SQLiteOpenHelper; import android.net.Uri; import android.text.TextUtils; import android.util.Log; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.Telemetry; -import org.mozilla.gecko.mozglue.RobocopTarget; import java.util.Map; diff --git a/mobile/android/base/db/LocalBrowserDB.java b/mobile/android/base/db/LocalBrowserDB.java index a92ee5554e4b..3ee673694616 100644 --- a/mobile/android/base/db/LocalBrowserDB.java +++ b/mobile/android/base/db/LocalBrowserDB.java @@ -24,6 +24,7 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.mozilla.gecko.AboutPages; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.AppConstants; import org.mozilla.gecko.R; import org.mozilla.gecko.db.BrowserContract.Bookmarks; @@ -39,7 +40,6 @@ import org.mozilla.gecko.distribution.Distribution; import org.mozilla.gecko.favicons.decoders.FaviconDecoder; import org.mozilla.gecko.favicons.decoders.LoadFaviconResult; import org.mozilla.gecko.gfx.BitmapUtils; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.sync.Utils; import org.mozilla.gecko.util.GeckoJarReader; import org.mozilla.gecko.util.StringUtils; diff --git a/mobile/android/base/db/LocalReadingListAccessor.java b/mobile/android/base/db/LocalReadingListAccessor.java index 3bac122e1da9..850e313943b8 100644 --- a/mobile/android/base/db/LocalReadingListAccessor.java +++ b/mobile/android/base/db/LocalReadingListAccessor.java @@ -13,11 +13,11 @@ import android.database.Cursor; import android.net.Uri; import android.util.Log; import org.mozilla.gecko.AboutPages; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.GeckoAppShell; import org.mozilla.gecko.GeckoEvent; import org.mozilla.gecko.ReaderModeUtils; import org.mozilla.gecko.db.BrowserContract.ReadingListItems; -import org.mozilla.gecko.mozglue.RobocopTarget; @RobocopTarget diff --git a/mobile/android/base/db/ReadingListAccessor.java b/mobile/android/base/db/ReadingListAccessor.java index b63687dd235c..b1ff8fdc2cd3 100644 --- a/mobile/android/base/db/ReadingListAccessor.java +++ b/mobile/android/base/db/ReadingListAccessor.java @@ -9,7 +9,7 @@ import android.content.ContentValues; import android.content.Context; import android.database.ContentObserver; import android.database.Cursor; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; @RobocopTarget public interface ReadingListAccessor { diff --git a/mobile/android/base/db/StubBrowserDB.java b/mobile/android/base/db/StubBrowserDB.java index f5b5f24ad379..877074cf7269 100644 --- a/mobile/android/base/db/StubBrowserDB.java +++ b/mobile/android/base/db/StubBrowserDB.java @@ -13,10 +13,10 @@ import java.util.List; import java.util.Map; import org.json.JSONObject; -import org.mozilla.gecko.Tab; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.distribution.Distribution; import org.mozilla.gecko.favicons.decoders.LoadFaviconResult; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.Tab; import android.content.ContentProviderOperation; import android.content.ContentResolver; diff --git a/mobile/android/base/db/SuggestedSites.java b/mobile/android/base/db/SuggestedSites.java index 58434e747bfd..3708435c121e 100644 --- a/mobile/android/base/db/SuggestedSites.java +++ b/mobile/android/base/db/SuggestedSites.java @@ -34,6 +34,7 @@ import java.util.Set; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.GeckoSharedPrefs; import org.mozilla.gecko.GeckoProfile; import org.mozilla.gecko.Locales; @@ -41,7 +42,6 @@ import org.mozilla.gecko.R; import org.mozilla.gecko.distribution.Distribution; import org.mozilla.gecko.db.BrowserContract; import org.mozilla.gecko.RestrictedProfiles; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.preferences.GeckoPreferences; import org.mozilla.gecko.util.RawResource; import org.mozilla.gecko.util.ThreadUtils; diff --git a/mobile/android/base/db/TopSitesCursorWrapper.java b/mobile/android/base/db/TopSitesCursorWrapper.java index d83dc129008e..a546f1563eb0 100644 --- a/mobile/android/base/db/TopSitesCursorWrapper.java +++ b/mobile/android/base/db/TopSitesCursorWrapper.java @@ -486,6 +486,11 @@ public class TopSitesCursorWrapper implements Cursor { throw new UnsupportedOperationException(); } + // @Override - Method has been introduced in Android M. Add @Override annotation as soon as we are building with the M SDK - Bug 1193205 + public void setExtras(Bundle extras) { + throw new UnsupportedOperationException(); + } + @Override public boolean getWantsAllOnMoveCalls() { return false; diff --git a/mobile/android/base/distribution/Distribution.java b/mobile/android/base/distribution/Distribution.java index 1cb9d508711d..12e11b44abb7 100644 --- a/mobile/android/base/distribution/Distribution.java +++ b/mobile/android/base/distribution/Distribution.java @@ -36,12 +36,12 @@ import ch.boye.httpclientandroidlib.protocol.HTTP; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.AppConstants; import org.mozilla.gecko.GeckoAppShell; import org.mozilla.gecko.GeckoEvent; import org.mozilla.gecko.GeckoSharedPrefs; import org.mozilla.gecko.Telemetry; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.util.FileUtils; import org.mozilla.gecko.util.HardwareUtils; import org.mozilla.gecko.util.ThreadUtils; diff --git a/mobile/android/base/distribution/ReferrerDescriptor.java b/mobile/android/base/distribution/ReferrerDescriptor.java index f422810ed14f..981756c8c7e2 100644 --- a/mobile/android/base/distribution/ReferrerDescriptor.java +++ b/mobile/android/base/distribution/ReferrerDescriptor.java @@ -4,7 +4,7 @@ package org.mozilla.gecko.distribution; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; import android.net.Uri; diff --git a/mobile/android/base/distribution/ReferrerReceiver.java b/mobile/android/base/distribution/ReferrerReceiver.java index 1c41b7bd40a9..2d75fbbf6b90 100644 --- a/mobile/android/base/distribution/ReferrerReceiver.java +++ b/mobile/android/base/distribution/ReferrerReceiver.java @@ -6,10 +6,10 @@ package org.mozilla.gecko.distribution; import org.mozilla.gecko.AdjustConstants; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.AppConstants; import org.mozilla.gecko.GeckoAppShell; import org.mozilla.gecko.GeckoEvent; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.json.JSONException; import org.json.JSONObject; diff --git a/mobile/android/base/fxa/activities/FxAccountAbstractSetupActivity.java b/mobile/android/base/fxa/activities/FxAccountAbstractSetupActivity.java index 9be939c99639..4bf4e53c90d3 100644 --- a/mobile/android/base/fxa/activities/FxAccountAbstractSetupActivity.java +++ b/mobile/android/base/fxa/activities/FxAccountAbstractSetupActivity.java @@ -32,6 +32,7 @@ import org.mozilla.gecko.sync.SyncConfiguration; import org.mozilla.gecko.sync.Utils; import org.mozilla.gecko.sync.setup.Constants; import org.mozilla.gecko.sync.setup.activities.ActivityUtils; +import org.mozilla.gecko.util.ColorUtils; import android.accounts.Account; import android.accounts.AccountManager; @@ -135,12 +136,12 @@ abstract public class FxAccountAbstractSetupActivity extends FxAccountAbstractAc passwordEdit.setTransformationMethod(PasswordTransformationMethod.getInstance()); showPasswordButton.setText(R.string.fxaccount_password_show); showPasswordButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.fxaccount_password_button_show_background)); - showPasswordButton.setTextColor(getResources().getColor(R.color.fxaccount_password_show_textcolor)); + showPasswordButton.setTextColor(ColorUtils.getColor(this, R.color.fxaccount_password_show_textcolor)); } else { passwordEdit.setTransformationMethod(SingleLineTransformationMethod.getInstance()); showPasswordButton.setText(R.string.fxaccount_password_hide); showPasswordButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.fxaccount_password_button_hide_background)); - showPasswordButton.setTextColor(getResources().getColor(R.color.fxaccount_password_hide_textcolor)); + showPasswordButton.setTextColor(ColorUtils.getColor(this, R.color.fxaccount_password_hide_textcolor)); } passwordEdit.setSelection(start, stop); } diff --git a/mobile/android/base/gfx/GeckoLayerClient.java b/mobile/android/base/gfx/GeckoLayerClient.java index 612f27859473..cfa1ff5aef45 100644 --- a/mobile/android/base/gfx/GeckoLayerClient.java +++ b/mobile/android/base/gfx/GeckoLayerClient.java @@ -5,6 +5,7 @@ package org.mozilla.gecko.gfx; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.annotation.WrapForJNI; import org.mozilla.gecko.GeckoAppShell; import org.mozilla.gecko.GeckoEvent; @@ -12,7 +13,6 @@ import org.mozilla.gecko.gfx.LayerView.DrawListener; import org.mozilla.gecko.Tab; import org.mozilla.gecko.Tabs; import org.mozilla.gecko.ZoomConstraints; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.EventDispatcher; import org.mozilla.gecko.util.FloatUtils; import org.mozilla.gecko.AppConstants; diff --git a/mobile/android/base/gfx/LayerRenderer.java b/mobile/android/base/gfx/LayerRenderer.java index 437a2ae63892..bce023303b98 100644 --- a/mobile/android/base/gfx/LayerRenderer.java +++ b/mobile/android/base/gfx/LayerRenderer.java @@ -28,7 +28,7 @@ import android.opengl.GLES20; import android.os.SystemClock; import android.util.Log; -import org.mozilla.gecko.mozglue.JNITarget; +import org.mozilla.gecko.annotation.JNITarget; import org.mozilla.gecko.util.ThreadUtils; import java.nio.ByteBuffer; diff --git a/mobile/android/base/gfx/LayerView.java b/mobile/android/base/gfx/LayerView.java index 8fa2820d56a7..56faaf49e8f0 100644 --- a/mobile/android/base/gfx/LayerView.java +++ b/mobile/android/base/gfx/LayerView.java @@ -10,6 +10,7 @@ import java.nio.IntBuffer; import java.util.ArrayList; import org.mozilla.gecko.AndroidGamepadManager; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.annotation.WrapForJNI; import org.mozilla.gecko.AppConstants.Versions; import org.mozilla.gecko.EventDispatcher; @@ -20,7 +21,6 @@ import org.mozilla.gecko.PrefsHelper; import org.mozilla.gecko.Tab; import org.mozilla.gecko.Tabs; import org.mozilla.gecko.ZoomConstraints; -import org.mozilla.gecko.mozglue.RobocopTarget; import android.content.Context; import android.graphics.Bitmap; diff --git a/mobile/android/base/gfx/PanningPerfAPI.java b/mobile/android/base/gfx/PanningPerfAPI.java index c4b9e4e55056..4507e30dbf22 100644 --- a/mobile/android/base/gfx/PanningPerfAPI.java +++ b/mobile/android/base/gfx/PanningPerfAPI.java @@ -5,7 +5,7 @@ package org.mozilla.gecko.gfx; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; import android.os.SystemClock; import android.util.Log; diff --git a/mobile/android/base/home/BrowserSearch.java b/mobile/android/base/home/BrowserSearch.java index 8c46a7521967..7b898053b869 100644 --- a/mobile/android/base/home/BrowserSearch.java +++ b/mobile/android/base/home/BrowserSearch.java @@ -14,6 +14,7 @@ import java.util.Locale; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.EventDispatcher; import org.mozilla.gecko.GeckoAppShell; import org.mozilla.gecko.GeckoEvent; @@ -28,7 +29,6 @@ import org.mozilla.gecko.db.BrowserContract.History; import org.mozilla.gecko.db.BrowserContract.URLColumns; import org.mozilla.gecko.home.HomePager.OnUrlOpenListener; import org.mozilla.gecko.home.SearchLoader.SearchCursorLoader; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.toolbar.AutocompleteHandler; import org.mozilla.gecko.util.GeckoEventListener; import org.mozilla.gecko.util.StringUtils; diff --git a/mobile/android/base/home/HomeConfig.java b/mobile/android/base/home/HomeConfig.java index 6bab4c2eab4d..4676548e17c5 100644 --- a/mobile/android/base/home/HomeConfig.java +++ b/mobile/android/base/home/HomeConfig.java @@ -17,10 +17,10 @@ import java.util.Map; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.GeckoAppShell; import org.mozilla.gecko.GeckoEvent; import org.mozilla.gecko.R; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.util.ThreadUtils; import android.content.Context; diff --git a/mobile/android/base/home/HomePagerTabStrip.java b/mobile/android/base/home/HomePagerTabStrip.java index 7edff5a0c072..3177ddf1f798 100644 --- a/mobile/android/base/home/HomePagerTabStrip.java +++ b/mobile/android/base/home/HomePagerTabStrip.java @@ -9,6 +9,7 @@ import org.mozilla.gecko.R; import org.mozilla.gecko.animation.BounceAnimatorBuilder; import org.mozilla.gecko.animation.BounceAnimatorBuilder.Attributes; import org.mozilla.gecko.animation.TransitionsTracker; +import org.mozilla.gecko.util.ColorUtils; import android.content.Context; import android.content.res.Resources; @@ -60,7 +61,7 @@ class HomePagerTabStrip extends PagerTabStrip { shadowSize = res.getDimensionPixelSize(R.dimen.tabs_strip_shadow_size); shadowPaint = new Paint(); - shadowPaint.setColor(res.getColor(R.color.url_bar_shadow)); + shadowPaint.setColor(ColorUtils.getColor(context, R.color.url_bar_shadow)); shadowPaint.setStrokeWidth(0.0f); getViewTreeObserver().addOnPreDrawListener(new PreDrawListener()); diff --git a/mobile/android/base/home/PanelRecyclerView.java b/mobile/android/base/home/PanelRecyclerView.java index b07f8de7e4fc..9145ab1e1ca4 100644 --- a/mobile/android/base/home/PanelRecyclerView.java +++ b/mobile/android/base/home/PanelRecyclerView.java @@ -143,11 +143,26 @@ public class PanelRecyclerView extends RecyclerView @Override public boolean onItemLongClicked(RecyclerView recyclerView, int position, View v) { + if (viewConfig.hasHeaderConfig()) { + if (position == 0) { + final HomeConfig.HeaderConfig headerConfig = viewConfig.getHeaderConfig(); + + final HomeContextMenuInfo info = new HomeContextMenuInfo(v, position, -1); + info.url = headerConfig.getUrl(); + info.title = headerConfig.getUrl(); + + contextMenuInfo = info; + return showContextMenuForChild(this); + } + + position--; + } + Cursor cursor = adapter.getCursor(); cursor.moveToPosition(position); contextMenuInfo = contextMenuInfoFactory.makeInfoForCursor(recyclerView, position, -1, cursor); - return showContextMenuForChild(PanelRecyclerView.this); + return showContextMenuForChild(this); } private class PanelSpanSizeLookup extends GridLayoutManager.SpanSizeLookup { diff --git a/mobile/android/base/home/SearchEngineAdapter.java b/mobile/android/base/home/SearchEngineAdapter.java index 2226aa070e88..a833c8e68bac 100644 --- a/mobile/android/base/home/SearchEngineAdapter.java +++ b/mobile/android/base/home/SearchEngineAdapter.java @@ -11,6 +11,7 @@ import android.view.ViewGroup; import android.widget.ImageView; import org.mozilla.gecko.R; +import org.mozilla.gecko.util.ColorUtils; import java.util.Collections; import java.util.List; @@ -102,7 +103,7 @@ public class SearchEngineAdapter .inflate(R.layout.search_engine_bar_label, parent, false); final Drawable icon = DrawableCompat.wrap( ContextCompat.getDrawable(mContext, R.drawable.search_icon_active).mutate()); - DrawableCompat.setTint(icon, mContext.getResources().getColor(R.color.disabled_grey)); + DrawableCompat.setTint(icon, ColorUtils.getColor(mContext, R.color.disabled_grey)); final ImageView iconView = (ImageView) view.findViewById(R.id.search_engine_label); iconView.setImageDrawable(icon); diff --git a/mobile/android/base/home/SearchEngineBar.java b/mobile/android/base/home/SearchEngineBar.java index 223c7166d911..019bb0bfc423 100644 --- a/mobile/android/base/home/SearchEngineBar.java +++ b/mobile/android/base/home/SearchEngineBar.java @@ -15,8 +15,9 @@ import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.View; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.R; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.util.ColorUtils; import org.mozilla.gecko.widget.RecyclerViewClickSupport; import java.util.List; @@ -47,7 +48,7 @@ public class SearchEngineBar extends RecyclerView super(context, attrs); mDividerPaint = new Paint(); - mDividerPaint.setColor(getResources().getColor(R.color.divider_light)); + mDividerPaint.setColor(ColorUtils.getColor(context, R.color.divider_light)); mDividerPaint.setStyle(Paint.Style.FILL_AND_STROKE); final DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); diff --git a/mobile/android/base/home/TabMenuStrip.java b/mobile/android/base/home/TabMenuStrip.java index fc6311f2ae82..ceba4ca67dc9 100644 --- a/mobile/android/base/home/TabMenuStrip.java +++ b/mobile/android/base/home/TabMenuStrip.java @@ -6,6 +6,7 @@ package org.mozilla.gecko.home; import org.mozilla.gecko.R; +import org.mozilla.gecko.util.ColorUtils; import android.content.Context; import android.content.res.Resources; @@ -56,7 +57,7 @@ public class TabMenuStrip extends HorizontalScrollView shadowSize = res.getDimensionPixelSize(R.dimen.tabs_strip_shadow_size); shadowPaint = new Paint(); - shadowPaint.setColor(res.getColor(R.color.url_bar_shadow)); + shadowPaint.setColor(ColorUtils.getColor(context, R.color.url_bar_shadow)); shadowPaint.setStrokeWidth(0.0f); } diff --git a/mobile/android/base/home/TabMenuStripLayout.java b/mobile/android/base/home/TabMenuStripLayout.java index eb231f72616c..78caee023d94 100644 --- a/mobile/android/base/home/TabMenuStripLayout.java +++ b/mobile/android/base/home/TabMenuStripLayout.java @@ -6,6 +6,7 @@ package org.mozilla.gecko.home; import org.mozilla.gecko.R; +import org.mozilla.gecko.util.ColorUtils; import android.content.Context; import android.content.res.TypedArray; @@ -79,7 +80,7 @@ class TabMenuStripLayout extends LinearLayout } selectedView = (TextView) getChildAt(position); - selectedView.setTextColor(getResources().getColor(R.color.placeholder_grey)); + selectedView.setTextColor(ColorUtils.getColor(getContext(), R.color.placeholder_grey)); // Callback to measure and draw the strip after the view is visible. ViewTreeObserver vto = selectedView.getViewTreeObserver(); diff --git a/mobile/android/base/home/TopSitesThumbnailView.java b/mobile/android/base/home/TopSitesThumbnailView.java index fed2698445c6..8e26884018f4 100644 --- a/mobile/android/base/home/TopSitesThumbnailView.java +++ b/mobile/android/base/home/TopSitesThumbnailView.java @@ -7,6 +7,7 @@ package org.mozilla.gecko.home; import org.mozilla.gecko.R; import org.mozilla.gecko.ThumbnailHelper; +import org.mozilla.gecko.util.ColorUtils; import org.mozilla.gecko.util.HardwareUtils; import android.content.Context; @@ -38,7 +39,7 @@ public class TopSitesThumbnailView extends ImageView { private Matrix mLayoutNextMatrix = new Matrix(); // Default filter color for "Add a bookmark" views. - private final int mDefaultColor = getResources().getColor(R.color.top_site_default); + private final int mDefaultColor = ColorUtils.getColor(getContext(), R.color.top_site_default); // Stroke width for the border. private final float mStrokeWidth = getResources().getDisplayMetrics().density * 2; @@ -68,7 +69,7 @@ public class TopSitesThumbnailView extends ImageView { // Initialize the border paint. final Resources res = getResources(); mBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG); - mBorderPaint.setColor(res.getColor(R.color.top_site_border)); + mBorderPaint.setColor(ColorUtils.getColor(context, R.color.top_site_border)); mBorderPaint.setStyle(Paint.Style.STROKE); } diff --git a/mobile/android/base/menu/MenuItemActionBar.java b/mobile/android/base/menu/MenuItemActionBar.java index 8e3266714769..c36886419265 100644 --- a/mobile/android/base/menu/MenuItemActionBar.java +++ b/mobile/android/base/menu/MenuItemActionBar.java @@ -5,9 +5,12 @@ package org.mozilla.gecko.menu; import org.mozilla.gecko.R; +import org.mozilla.gecko.util.DrawableUtil; import org.mozilla.gecko.widget.ThemedImageButton; import android.content.Context; +import android.content.res.ColorStateList; +import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.util.AttributeSet; @@ -15,6 +18,8 @@ public class MenuItemActionBar extends ThemedImageButton implements GeckoMenuItem.Layout { private static final String LOGTAG = "GeckoMenuItemActionBar"; + private final ColorStateList drawableColors; + public MenuItemActionBar(Context context) { this(context, null); } @@ -25,6 +30,10 @@ public class MenuItemActionBar extends ThemedImageButton public MenuItemActionBar(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); + + final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MenuItemActionBar, defStyle, 0); + drawableColors = ta.getColorStateList(R.styleable.MenuItemActionBar_drawableTintList); + ta.recycle(); } @Override @@ -43,6 +52,7 @@ public class MenuItemActionBar extends ThemedImageButton setVisibility(GONE); } else { setVisibility(VISIBLE); + DrawableUtil.tintDrawableWithStateList(icon, drawableColors); setImageDrawable(icon); } } @@ -56,12 +66,6 @@ public class MenuItemActionBar extends ThemedImageButton setContentDescription(title); } - @Override - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - setColorFilter(enabled ? 0 : 0xFF999999); - } - @Override public void setShowIcon(boolean show) { // Do nothing. diff --git a/mobile/android/base/moz.build b/mobile/android/base/moz.build index ceaccb87044f..82e16da0dbf1 100644 --- a/mobile/android/base/moz.build +++ b/mobile/android/base/moz.build @@ -14,6 +14,9 @@ thirdparty_source_dir = TOPSRCDIR + '/mobile/android/thirdparty/' constants_jar = add_java_jar('constants') constants_jar.sources = [ 'adjust/AdjustHelperInterface.java', + 'annotation/JNITarget.java', + 'annotation/RobocopTarget.java', + 'annotation/WebRTCJNITarget.java', 'annotation/WrapForJNI.java', 'SysInfo.java', ] @@ -56,11 +59,8 @@ mgjar.sources += [ 'mozglue/DirectBufferAllocator.java', 'mozglue/GeckoLoader.java', 'mozglue/JNIObject.java', - 'mozglue/JNITarget.java', 'mozglue/NativeReference.java', 'mozglue/NativeZip.java', - 'mozglue/RobocopTarget.java', - 'mozglue/WebRTCJNITarget.java', ] mgjar.generated_sources = [] # Keep it this way. mgjar.extra_jars += [ @@ -74,6 +74,7 @@ gujar.sources += [ 'util/ActivityResultHandlerMap.java', 'util/ActivityUtils.java', 'util/Clipboard.java', + 'util/ColorUtils.java', 'util/DrawableUtil.java', 'util/EventCallback.java', 'util/FileUtils.java', diff --git a/mobile/android/base/mozglue/GeckoLoader.java b/mobile/android/base/mozglue/GeckoLoader.java index 646b33a49561..5a28b0e451b9 100644 --- a/mobile/android/base/mozglue/GeckoLoader.java +++ b/mobile/android/base/mozglue/GeckoLoader.java @@ -21,6 +21,8 @@ import android.os.Build; import android.os.Environment; import android.util.Log; +import org.mozilla.gecko.annotation.JNITarget; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.AppConstants; import org.mozilla.gecko.mozglue.ContextUtils.SafeIntent; diff --git a/mobile/android/base/mozglue/NativeZip.java b/mobile/android/base/mozglue/NativeZip.java index 8a35d155fb91..be2f76390faa 100644 --- a/mobile/android/base/mozglue/NativeZip.java +++ b/mobile/android/base/mozglue/NativeZip.java @@ -5,7 +5,7 @@ package org.mozilla.gecko.mozglue; -import org.mozilla.gecko.mozglue.JNITarget; +import org.mozilla.gecko.annotation.JNITarget; import java.io.InputStream; import java.nio.ByteBuffer; diff --git a/mobile/android/base/resources/color-large-v11/action_bar_menu_item_colors.xml b/mobile/android/base/resources/color-large-v11/action_bar_menu_item_colors.xml new file mode 100644 index 000000000000..756463d68c9a --- /dev/null +++ b/mobile/android/base/resources/color-large-v11/action_bar_menu_item_colors.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + diff --git a/mobile/android/base/resources/color-large-v11/action_bar_secondary_menu_item_colors.xml b/mobile/android/base/resources/color-large-v11/action_bar_secondary_menu_item_colors.xml new file mode 100644 index 000000000000..c72ce0923f83 --- /dev/null +++ b/mobile/android/base/resources/color-large-v11/action_bar_secondary_menu_item_colors.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/mobile/android/base/resources/color-large-v11/tabs_counter_text_color.xml b/mobile/android/base/resources/color-large-v11/tabs_counter_text_color.xml new file mode 100644 index 000000000000..945634b7a670 --- /dev/null +++ b/mobile/android/base/resources/color-large-v11/tabs_counter_text_color.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/mobile/android/base/resources/color/url_bar_title.xml b/mobile/android/base/resources/color/url_bar_title.xml index e438979af1ef..473bee41d289 100644 --- a/mobile/android/base/resources/color/url_bar_title.xml +++ b/mobile/android/base/resources/color/url_bar_title.xml @@ -7,10 +7,10 @@ xmlns:gecko="http://schemas.android.com/apk/res-auto"> - + - + diff --git a/mobile/android/base/resources/drawable-large-v11/new_tablet_action_bar_button.xml b/mobile/android/base/resources/drawable-large-v11/new_tablet_action_bar_button.xml index 54dedbe256c3..b7f7f014ce2d 100644 --- a/mobile/android/base/resources/drawable-large-v11/new_tablet_action_bar_button.xml +++ b/mobile/android/base/resources/drawable-large-v11/new_tablet_action_bar_button.xml @@ -15,7 +15,7 @@ android:insetLeft="@dimen/new_tablet_browser_toolbar_menu_item_inset_horizontal" android:insetRight="@dimen/new_tablet_browser_toolbar_menu_item_inset_horizontal"> - + @@ -31,7 +31,7 @@ android:insetLeft="@dimen/new_tablet_browser_toolbar_menu_item_inset_horizontal" android:insetRight="@dimen/new_tablet_browser_toolbar_menu_item_inset_horizontal"> - + diff --git a/mobile/android/base/resources/drawable-large-v11/new_tablet_url_bar_nav_button.xml b/mobile/android/base/resources/drawable-large-v11/new_tablet_url_bar_nav_button.xml index c71774713e1e..3027357ec78d 100644 --- a/mobile/android/base/resources/drawable-large-v11/new_tablet_url_bar_nav_button.xml +++ b/mobile/android/base/resources/drawable-large-v11/new_tablet_url_bar_nav_button.xml @@ -9,13 +9,13 @@ + android:drawable="@color/text_and_tabs_tray_grey"/> + android:drawable="@color/placeholder_active_grey"/> + + + + + + + + + + + + + + + + + + + + + + @@ -33,6 +57,19 @@ + + + + + + + + + - + + + + android:drawable="@drawable/tabs_panel_indicator_selected"/> + + + diff --git a/mobile/android/base/resources/drawable/tabs_panel_indicator_selected_private.xml b/mobile/android/base/resources/drawable/tabs_panel_indicator_selected_private.xml new file mode 100644 index 000000000000..93dc0498650c --- /dev/null +++ b/mobile/android/base/resources/drawable/tabs_panel_indicator_selected_private.xml @@ -0,0 +1,9 @@ + + + + diff --git a/mobile/android/base/resources/drawable/tabs_strip_indicator.xml b/mobile/android/base/resources/drawable/tabs_strip_indicator.xml new file mode 100644 index 000000000000..32ca3115a28b --- /dev/null +++ b/mobile/android/base/resources/drawable/tabs_strip_indicator.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/mobile/android/base/resources/layout-large-v11/new_tablet_tabs_counter.xml b/mobile/android/base/resources/layout-large-v11/new_tablet_tabs_counter.xml index 0f73b6591eb7..bb3217fe79ef 100644 --- a/mobile/android/base/resources/layout-large-v11/new_tablet_tabs_counter.xml +++ b/mobile/android/base/resources/layout-large-v11/new_tablet_tabs_counter.xml @@ -10,7 +10,7 @@ android:paddingLeft="4dip" android:background="@drawable/new_tablet_tabs_count_foreground" android:textAppearance="@style/TextAppearance.Micro" - android:textColor="@color/toolbar_grey" + android:textColor="@color/tabs_counter_text_color" android:textStyle="bold" android:duplicateParentState="true" android:gravity="center"/> diff --git a/mobile/android/base/resources/layout-v11/new_tablet_tabs_item_cell.xml b/mobile/android/base/resources/layout-v11/new_tablet_tabs_item_cell.xml index 204eba2df91f..32b5a680f211 100644 --- a/mobile/android/base/resources/layout-v11/new_tablet_tabs_item_cell.xml +++ b/mobile/android/base/resources/layout-v11/new_tablet_tabs_item_cell.xml @@ -57,6 +57,7 @@ + - - + android:clickable="true" + android:foreground="@color/recyclerview_selector"> diff --git a/mobile/android/base/resources/layout/tab_menu_strip.xml b/mobile/android/base/resources/layout/tab_menu_strip.xml index 1b768bb5b2ed..17f918a0aba3 100644 --- a/mobile/android/base/resources/layout/tab_menu_strip.xml +++ b/mobile/android/base/resources/layout/tab_menu_strip.xml @@ -7,7 +7,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:minWidth="@dimen/tabs_strip_button_width" - android:background="@drawable/tabs_panel_indicator" + android:background="@drawable/tabs_strip_indicator" android:paddingLeft="@dimen/tabs_strip_button_padding" android:paddingRight="@dimen/tabs_strip_button_padding" android:gravity="center" diff --git a/mobile/android/base/resources/layout/tabs_item_cell.xml b/mobile/android/base/resources/layout/tabs_item_cell.xml index 2c6483ec07ee..712bbdadb037 100644 --- a/mobile/android/base/resources/layout/tabs_item_cell.xml +++ b/mobile/android/base/resources/layout/tabs_item_cell.xml @@ -15,6 +15,7 @@ android:paddingRight="1dip" android:gravity="center"> + - + - + diff --git a/mobile/android/base/resources/values-large-v11/dimens.xml b/mobile/android/base/resources/values-large-v11/dimens.xml index 1d9063d60eba..deeb2f2def34 100644 --- a/mobile/android/base/resources/values-large-v11/dimens.xml +++ b/mobile/android/base/resources/values-large-v11/dimens.xml @@ -8,6 +8,11 @@ 100dp 56dp + + 50dp + 60dp 16dp 16dp diff --git a/mobile/android/base/resources/values-large-v11/styles.xml b/mobile/android/base/resources/values-large-v11/styles.xml index 5ed98e069dc7..788cdc05f5a8 100644 --- a/mobile/android/base/resources/values-large-v11/styles.xml +++ b/mobile/android/base/resources/values-large-v11/styles.xml @@ -78,6 +78,7 @@ wrap_content wrap_content @drawable/new_tablet_action_bar_button + @color/action_bar_menu_item_colors center - + + + + diff --git a/mobile/android/base/resources/values-xlarge-v11/dimens.xml b/mobile/android/base/resources/values-xlarge-v11/dimens.xml index 8e38c4587ea0..f27050f6ca9d 100644 --- a/mobile/android/base/resources/values-xlarge-v11/dimens.xml +++ b/mobile/android/base/resources/values-xlarge-v11/dimens.xml @@ -5,7 +5,6 @@ - 56dp 250dp 48dp diff --git a/mobile/android/base/resources/values/attrs.xml b/mobile/android/base/resources/values/attrs.xml index b33cf4380338..eb62f3c15a25 100644 --- a/mobile/android/base/resources/values/attrs.xml +++ b/mobile/android/base/resources/values/attrs.xml @@ -196,5 +196,11 @@ + + + + + diff --git a/mobile/android/base/resources/values/colors.xml b/mobile/android/base/resources/values/colors.xml index 71ff06163f87..9cc767dce18d 100644 --- a/mobile/android/base/resources/values/colors.xml +++ b/mobile/android/base/resources/values/colors.xml @@ -152,4 +152,6 @@ #FFECF0F3 #FFCFD9E1 + #FFFFFF + diff --git a/mobile/android/base/resources/values/dimens.xml b/mobile/android/base/resources/values/dimens.xml index 16fe548ad258..675ce2deb6a4 100644 --- a/mobile/android/base/resources/values/dimens.xml +++ b/mobile/android/base/resources/values/dimens.xml @@ -11,6 +11,11 @@ 32dp 48dp + + 42dp + 48dp diff --git a/mobile/android/base/resources/values/styles.xml b/mobile/android/base/resources/values/styles.xml index b409ae0a63f5..79694da514d9 100644 --- a/mobile/android/base/resources/values/styles.xml +++ b/mobile/android/base/resources/values/styles.xml @@ -90,12 +90,16 @@ fitCenter - + + @@ -757,7 +761,7 @@ diff --git a/mobile/android/base/sqlite/SQLiteBridge.java b/mobile/android/base/sqlite/SQLiteBridge.java index 072e63bf815c..9ad88dca02c6 100644 --- a/mobile/android/base/sqlite/SQLiteBridge.java +++ b/mobile/android/base/sqlite/SQLiteBridge.java @@ -11,7 +11,7 @@ import android.database.sqlite.SQLiteException; import android.text.TextUtils; import android.util.Log; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; import java.util.ArrayList; import java.util.Arrays; diff --git a/mobile/android/base/tabs/TabStrip.java b/mobile/android/base/tabs/TabStrip.java index b20c83da2daf..d28ead7b2ef5 100644 --- a/mobile/android/base/tabs/TabStrip.java +++ b/mobile/android/base/tabs/TabStrip.java @@ -19,6 +19,7 @@ import org.mozilla.gecko.BrowserApp.Refreshable; import org.mozilla.gecko.R; import org.mozilla.gecko.Tab; import org.mozilla.gecko.Tabs; +import org.mozilla.gecko.util.ColorUtils; import org.mozilla.gecko.widget.ThemedImageButton; import org.mozilla.gecko.widget.ThemedLinearLayout; @@ -152,7 +153,7 @@ public class TabStrip extends ThemedLinearLayout @Override public void onLightweightThemeReset() { - final int defaultBackgroundColor = getResources().getColor(R.color.text_and_tabs_tray_grey); + final int defaultBackgroundColor = ColorUtils.getColor(getContext(), R.color.text_and_tabs_tray_grey); setBackgroundColor(defaultBackgroundColor); } } diff --git a/mobile/android/base/tabs/TabsGridLayout.java b/mobile/android/base/tabs/TabsGridLayout.java index 5d8027da0b19..5c364f44e3c2 100644 --- a/mobile/android/base/tabs/TabsGridLayout.java +++ b/mobile/android/base/tabs/TabsGridLayout.java @@ -13,6 +13,7 @@ import org.mozilla.gecko.Tabs; import org.mozilla.gecko.animation.PropertyAnimator; import org.mozilla.gecko.animation.ViewHelper; import org.mozilla.gecko.tabs.TabsPanel.TabsLayout; +import org.mozilla.gecko.widget.ThemedRelativeLayout; import android.content.Context; import android.content.res.Resources; @@ -435,6 +436,7 @@ class TabsGridLayout extends GridView final TabsLayoutItemView item = super.newView(position, parent); item.setCloseOnClickListener(mCloseClickListener); + ((ThemedRelativeLayout) item.findViewById(R.id.wrapper)).setPrivateMode(mIsPrivate); return item; } diff --git a/mobile/android/base/tabs/TabsListLayout.java b/mobile/android/base/tabs/TabsListLayout.java index 934ab5e6d3be..2e5a3ff36d00 100644 --- a/mobile/android/base/tabs/TabsListLayout.java +++ b/mobile/android/base/tabs/TabsListLayout.java @@ -18,6 +18,7 @@ import org.mozilla.gecko.Tab; import org.mozilla.gecko.tabs.TabsPanel.TabsLayout; import org.mozilla.gecko.Tabs; import org.mozilla.gecko.util.ThreadUtils; +import org.mozilla.gecko.widget.ThemedRelativeLayout; import org.mozilla.gecko.widget.TwoWayView; import android.content.Context; @@ -108,6 +109,7 @@ class TabsListLayout extends TwoWayView TabsLayoutItemView item = super.newView(position, parent); item.setCloseOnClickListener(mCloseOnClickListener); + ((ThemedRelativeLayout) item.findViewById(R.id.wrapper)).setPrivateMode(mIsPrivate); return item; } diff --git a/mobile/android/base/tabs/TabsPanel.java b/mobile/android/base/tabs/TabsPanel.java index cc8a0d3a0944..895cdd070563 100644 --- a/mobile/android/base/tabs/TabsPanel.java +++ b/mobile/android/base/tabs/TabsPanel.java @@ -19,6 +19,7 @@ import org.mozilla.gecko.animation.ViewHelper; import org.mozilla.gecko.lwt.LightweightTheme; import org.mozilla.gecko.lwt.LightweightThemeDrawable; import org.mozilla.gecko.restrictions.Restriction; +import org.mozilla.gecko.util.ColorUtils; import org.mozilla.gecko.util.HardwareUtils; import org.mozilla.gecko.widget.GeckoPopupMenu; import org.mozilla.gecko.widget.IconTabWidget; @@ -38,6 +39,7 @@ import android.widget.FrameLayout; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.RelativeLayout; +import org.mozilla.gecko.widget.ThemedImageButton; public class TabsPanel extends LinearLayout implements GeckoPopupMenu.OnMenuItemClickListener, @@ -139,7 +141,9 @@ public class TabsPanel extends LinearLayout mTabWidget = (IconTabWidget) findViewById(R.id.tab_widget); mTabWidget.addTab(R.drawable.tabs_normal, R.string.tabs_normal); - mTabWidget.addTab(R.drawable.tabs_private, R.string.tabs_private); + final ThemedImageButton privateTabsPanel = + (ThemedImageButton) mTabWidget.addTab(R.drawable.tabs_private, R.string.tabs_private); + privateTabsPanel.setPrivateMode(true); if (!RestrictedProfiles.isAllowed(mContext, Restriction.DISALLOW_PRIVATE_BROWSING)) { mTabWidget.setVisibility(View.GONE); @@ -281,7 +285,7 @@ public class TabsPanel extends LinearLayout @Override @SuppressWarnings("deprecation") // setBackgroundDrawable deprecated by API level 16 public void onLightweightThemeChanged() { - final int background = getResources().getColor(R.color.text_and_tabs_tray_grey); + final int background = ColorUtils.getColor(getContext(), R.color.text_and_tabs_tray_grey); final LightweightThemeDrawable drawable = mTheme.getColorDrawable(this, background, true); if (drawable == null) return; @@ -292,7 +296,7 @@ public class TabsPanel extends LinearLayout @Override public void onLightweightThemeReset() { - setBackgroundColor(getContext().getResources().getColor(R.color.text_and_tabs_tray_grey)); + setBackgroundColor(ColorUtils.getColor(getContext(), R.color.text_and_tabs_tray_grey)); } @Override @@ -352,7 +356,7 @@ public class TabsPanel extends LinearLayout @Override @SuppressWarnings("deprecation") // setBackgroundDrawable deprecated by API level 16 public void onLightweightThemeChanged() { - final int background = getResources().getColor(R.color.text_and_tabs_tray_grey); + final int background = ColorUtils.getColor(getContext(), R.color.text_and_tabs_tray_grey); final LightweightThemeDrawable drawable = mTheme.getColorDrawable(this, background); if (drawable == null) return; @@ -363,7 +367,7 @@ public class TabsPanel extends LinearLayout @Override public void onLightweightThemeReset() { - setBackgroundColor(getContext().getResources().getColor(R.color.text_and_tabs_tray_grey)); + setBackgroundColor(ColorUtils.getColor(getContext(), R.color.text_and_tabs_tray_grey)); } @Override diff --git a/mobile/android/base/toolbar/BrowserToolbar.java b/mobile/android/base/toolbar/BrowserToolbar.java index eebd5ddfa488..d2ed162dd165 100644 --- a/mobile/android/base/toolbar/BrowserToolbar.java +++ b/mobile/android/base/toolbar/BrowserToolbar.java @@ -29,6 +29,7 @@ import org.mozilla.gecko.toolbar.ToolbarDisplayLayout.OnStopListener; import org.mozilla.gecko.toolbar.ToolbarDisplayLayout.OnTitleChangeListener; import org.mozilla.gecko.toolbar.ToolbarDisplayLayout.UpdateFlags; import org.mozilla.gecko.util.Clipboard; +import org.mozilla.gecko.util.ColorUtils; import org.mozilla.gecko.util.HardwareUtils; import org.mozilla.gecko.util.MenuUtils; import org.mozilla.gecko.widget.ThemedImageButton; @@ -202,8 +203,8 @@ public abstract class BrowserToolbar extends ThemedRelativeLayout shadowSize = res.getDimensionPixelSize(R.dimen.browser_toolbar_shadow_size); shadowPaint = new Paint(); - shadowColor = res.getColor(R.color.url_bar_shadow); - shadowPrivateColor = res.getColor(R.color.url_bar_shadow_private); + shadowColor = ColorUtils.getColor(context, R.color.url_bar_shadow); + shadowPrivateColor = ColorUtils.getColor(context, R.color.url_bar_shadow_private); shadowPaint.setColor(shadowColor); shadowPaint.setStrokeWidth(0.0f); @@ -926,8 +927,8 @@ public abstract class BrowserToolbar extends ThemedRelativeLayout } public static LightweightThemeDrawable getLightweightThemeDrawable(final View view, - final Resources res, final LightweightTheme theme, final int colorResID) { - final int color = res.getColor(colorResID); + final LightweightTheme theme, final int colorResID) { + final int color = ColorUtils.getColor(view.getContext(), colorResID); final LightweightThemeDrawable drawable = theme.getColorDrawable(view, color); if (drawable != null) { diff --git a/mobile/android/base/toolbar/BrowserToolbarPhoneBase.java b/mobile/android/base/toolbar/BrowserToolbarPhoneBase.java index ae2be68b2763..1e39cac6debc 100644 --- a/mobile/android/base/toolbar/BrowserToolbarPhoneBase.java +++ b/mobile/android/base/toolbar/BrowserToolbarPhoneBase.java @@ -13,6 +13,7 @@ import org.mozilla.gecko.Telemetry; import org.mozilla.gecko.TelemetryContract; import org.mozilla.gecko.animation.PropertyAnimator; import org.mozilla.gecko.animation.ViewHelper; +import org.mozilla.gecko.util.ColorUtils; import org.mozilla.gecko.widget.ThemedImageView; import android.content.Context; @@ -63,7 +64,7 @@ abstract class BrowserToolbarPhoneBase extends BrowserToolbar { roundCornerPaint = new Paint(); roundCornerPaint.setAntiAlias(true); - roundCornerPaint.setColor(res.getColor(R.color.text_and_tabs_tray_grey)); + roundCornerPaint.setColor(ColorUtils.getColor(context, R.color.text_and_tabs_tray_grey)); roundCornerPaint.setStrokeWidth(0.0f); } diff --git a/mobile/android/base/toolbar/BrowserToolbarTablet.java b/mobile/android/base/toolbar/BrowserToolbarTablet.java index ccaffc99d51c..beba4240561a 100644 --- a/mobile/android/base/toolbar/BrowserToolbarTablet.java +++ b/mobile/android/base/toolbar/BrowserToolbarTablet.java @@ -206,7 +206,6 @@ class BrowserToolbarTablet extends BrowserToolbarTabletBase { @Override protected Drawable getLWTDefaultStateSetDrawable() { - return BrowserToolbar.getLightweightThemeDrawable(this, getResources(), getTheme(), - R.color.toolbar_grey); + return BrowserToolbar.getLightweightThemeDrawable(this, getTheme(), R.color.toolbar_grey); } } diff --git a/mobile/android/base/toolbar/BrowserToolbarTabletBase.java b/mobile/android/base/toolbar/BrowserToolbarTabletBase.java index 3371818d3b3d..555bfef7611d 100644 --- a/mobile/android/base/toolbar/BrowserToolbarTabletBase.java +++ b/mobile/android/base/toolbar/BrowserToolbarTabletBase.java @@ -12,8 +12,12 @@ import org.mozilla.gecko.Tab; import org.mozilla.gecko.Tabs; import org.mozilla.gecko.tabs.TabHistoryController; import org.mozilla.gecko.menu.MenuItemActionBar; +import org.mozilla.gecko.util.ColorUtils; +import org.mozilla.gecko.widget.ThemedTextView; import android.content.Context; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.View; @@ -37,6 +41,8 @@ abstract class BrowserToolbarTabletBase extends BrowserToolbar { protected final BackButton backButton; protected final ForwardButton forwardButton; + private final PorterDuffColorFilter privateBrowsingTabletMenuItemColorFilter; + protected abstract void animateForwardButton(ForwardButtonAnimation animation); public BrowserToolbarTabletBase(final Context context, final AttributeSet attrs) { @@ -55,6 +61,9 @@ abstract class BrowserToolbarTabletBase extends BrowserToolbar { focusOrder.addAll(Arrays.asList(actionItemBar, menuButton)); urlDisplayLayout.updateSiteIdentityAnchor(backButton); + + privateBrowsingTabletMenuItemColorFilter = new PorterDuffColorFilter( + ColorUtils.getColor(context, R.color.tabs_tray_icon_grey), PorterDuff.Mode.SRC_IN); } private void initButtonListeners() { @@ -121,6 +130,17 @@ abstract class BrowserToolbarTabletBase extends BrowserToolbar { public void setPrivateMode(final boolean isPrivate) { super.setPrivateMode(isPrivate); + // Better done with android:tint but it doesn't take a ColorStateList: + // https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=18220 + // Nor can we use DrawableCompat because the drawables (as opposed + // to the Views) don't receive gecko:state_private. + final PorterDuffColorFilter colorFilter = + isPrivate ? privateBrowsingTabletMenuItemColorFilter : null; + backButton.setColorFilter(colorFilter); + forwardButton.setColorFilter(colorFilter); + setTabsCounterPrivateMode(isPrivate, colorFilter); + menuIcon.setColorFilter(colorFilter); + backButton.setPrivateMode(isPrivate); forwardButton.setPrivateMode(isPrivate); for (int i = 0; i < actionItemBar.getChildCount(); ++i) { @@ -129,6 +149,20 @@ abstract class BrowserToolbarTabletBase extends BrowserToolbar { } } + private void setTabsCounterPrivateMode(final boolean isPrivate, final PorterDuffColorFilter colorFilter) { + // The TabsCounter is a TextSwitcher which cycles two views + // to provide animations, hence looping over these two children. + for (int i = 0; i < 2; ++i) { + final ThemedTextView view = (ThemedTextView) tabsCounter.getChildAt(i); + view.setPrivateMode(isPrivate); + view.getBackground().mutate().setColorFilter(colorFilter); + } + + // To prevent animation of the background, + // it is set to a different Drawable. + tabsCounter.getBackground().mutate().setColorFilter(colorFilter); + } + @Override public View getDoorHangerAnchor() { return backButton; diff --git a/mobile/android/base/toolbar/NavButton.java b/mobile/android/base/toolbar/NavButton.java index 5e300023dd74..8bd22653d4e3 100644 --- a/mobile/android/base/toolbar/NavButton.java +++ b/mobile/android/base/toolbar/NavButton.java @@ -5,6 +5,7 @@ package org.mozilla.gecko.toolbar; import org.mozilla.gecko.R; +import org.mozilla.gecko.util.ColorUtils; import android.content.Context; import android.content.res.Resources; @@ -27,8 +28,8 @@ abstract class NavButton extends ShapedButton { super(context, attrs); final Resources res = getResources(); - mBorderColor = res.getColor(R.color.disabled_grey); - mBorderColorPrivate = res.getColor(R.color.toolbar_icon_grey); + mBorderColor = ColorUtils.getColor(context, R.color.disabled_grey); + mBorderColorPrivate = ColorUtils.getColor(context, R.color.toolbar_icon_grey); mBorderWidth = res.getDimension(R.dimen.nav_button_border_width); // Paint to draw the border. @@ -60,8 +61,7 @@ abstract class NavButton extends ShapedButton { // The drawable is constructed as per @drawable/new_tablet_url_bar_nav_button. @Override public void onLightweightThemeChanged() { - final Drawable drawable = BrowserToolbar.getLightweightThemeDrawable(this, getResources(), - getTheme(), R.color.toolbar_grey); + final Drawable drawable = BrowserToolbar.getLightweightThemeDrawable(this, getTheme(), R.color.toolbar_grey); if (drawable == null) { return; diff --git a/mobile/android/base/toolbar/ShapedButton.java b/mobile/android/base/toolbar/ShapedButton.java index 089fb0aed347..fb98a8b13fa6 100644 --- a/mobile/android/base/toolbar/ShapedButton.java +++ b/mobile/android/base/toolbar/ShapedButton.java @@ -9,6 +9,7 @@ import org.mozilla.gecko.R; import org.mozilla.gecko.lwt.LightweightTheme; import org.mozilla.gecko.lwt.LightweightThemeDrawable; import org.mozilla.gecko.tabs.TabCurve; +import org.mozilla.gecko.util.ColorUtils; import org.mozilla.gecko.widget.ThemedImageButton; import android.content.Context; @@ -35,7 +36,7 @@ public class ShapedButton extends ThemedImageButton final Paint paint = new Paint(); paint.setAntiAlias(true); - paint.setColor(getResources().getColor(R.color.canvas_delegate_paint)); + paint.setColor(ColorUtils.getColor(context, R.color.canvas_delegate_paint)); paint.setStrokeWidth(0.0f); mCanvasDelegate = new CanvasDelegate(this, Mode.DST_IN, paint); @@ -58,7 +59,7 @@ public class ShapedButton extends ThemedImageButton // The drawable is constructed as per @drawable/shaped_button. @Override public void onLightweightThemeChanged() { - final int background = getResources().getColor(R.color.text_and_tabs_tray_grey); + final int background = ColorUtils.getColor(getContext(), R.color.text_and_tabs_tray_grey); final LightweightThemeDrawable lightWeight = getTheme().getColorDrawable(this, background); if (lightWeight == null) diff --git a/mobile/android/base/toolbar/SiteIdentityPopup.java b/mobile/android/base/toolbar/SiteIdentityPopup.java index 885e95e12050..ec85f9a1b705 100644 --- a/mobile/android/base/toolbar/SiteIdentityPopup.java +++ b/mobile/android/base/toolbar/SiteIdentityPopup.java @@ -27,6 +27,7 @@ import org.mozilla.gecko.SiteIdentity.MixedMode; import org.mozilla.gecko.SiteIdentity.TrackingMode; import org.mozilla.gecko.Tab; import org.mozilla.gecko.Tabs; +import org.mozilla.gecko.util.ColorUtils; import org.mozilla.gecko.util.GeckoEventListener; import org.mozilla.gecko.util.ThreadUtils; import org.mozilla.gecko.widget.AnchoredPopup; @@ -338,13 +339,13 @@ public class SiteIdentityPopup extends AnchoredPopup implements GeckoEventListen } mSecurityState.setText(R.string.identity_connection_insecure); - mSecurityState.setTextColor(mResources.getColor(R.color.placeholder_active_grey)); + mSecurityState.setTextColor(ColorUtils.getColor(mContext, R.color.placeholder_active_grey)); } else { // Connection is secure. mIcon.setImageResource(R.drawable.lock_secure); setSecurityStateIcon(R.drawable.img_check, 2); - mSecurityState.setTextColor(mResources.getColor(R.color.affirmative_green)); + mSecurityState.setTextColor(ColorUtils.getColor(mContext, R.color.affirmative_green)); mSecurityState.setText(R.string.identity_connection_secure); // Mixed content has been blocked, if present. diff --git a/mobile/android/base/toolbar/ToolbarDisplayLayout.java b/mobile/android/base/toolbar/ToolbarDisplayLayout.java index eb6b1c9ae55e..bdafdf2a0af3 100644 --- a/mobile/android/base/toolbar/ToolbarDisplayLayout.java +++ b/mobile/android/base/toolbar/ToolbarDisplayLayout.java @@ -23,6 +23,7 @@ import org.mozilla.gecko.animation.PropertyAnimator; import org.mozilla.gecko.animation.ViewHelper; import org.mozilla.gecko.favicons.Favicons; import org.mozilla.gecko.toolbar.BrowserToolbarTabletBase.ForwardButtonAnimation; +import org.mozilla.gecko.util.ColorUtils; import org.mozilla.gecko.util.HardwareUtils; import org.mozilla.gecko.util.StringUtils; import org.mozilla.gecko.widget.ThemedLinearLayout; @@ -153,10 +154,10 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout final Resources res = getResources(); - mUrlColor = new ForegroundColorSpan(res.getColor(R.color.url_bar_urltext)); - mBlockedColor = new ForegroundColorSpan(res.getColor(R.color.url_bar_blockedtext)); - mDomainColor = new ForegroundColorSpan(res.getColor(R.color.url_bar_domaintext)); - mPrivateDomainColor = new ForegroundColorSpan(res.getColor(R.color.url_bar_domaintext_private)); + mUrlColor = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_urltext)); + mBlockedColor = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_blockedtext)); + mDomainColor = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_domaintext)); + mPrivateDomainColor = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_domaintext_private)); mFavicon = (ImageButton) findViewById(R.id.favicon); mSiteSecurity = (ImageButton) findViewById(R.id.site_security); diff --git a/mobile/android/base/toolbar/ToolbarEditText.java b/mobile/android/base/toolbar/ToolbarEditText.java index ff0d297bb20b..1ce7ff25b9b5 100644 --- a/mobile/android/base/toolbar/ToolbarEditText.java +++ b/mobile/android/base/toolbar/ToolbarEditText.java @@ -5,6 +5,7 @@ package org.mozilla.gecko.toolbar; +import org.mozilla.gecko.AboutPages; import org.mozilla.gecko.AppConstants.Versions; import org.mozilla.gecko.CustomEditText; import org.mozilla.gecko.InputMethods; @@ -12,11 +13,13 @@ import org.mozilla.gecko.R; import org.mozilla.gecko.toolbar.BrowserToolbar.OnCommitListener; import org.mozilla.gecko.toolbar.BrowserToolbar.OnDismissListener; import org.mozilla.gecko.toolbar.BrowserToolbar.OnFilterListener; +import org.mozilla.gecko.util.DrawableUtil; import org.mozilla.gecko.util.GamepadUtils; import org.mozilla.gecko.util.StringUtils; import org.mozilla.gecko.util.HardwareUtils; import android.content.Context; +import android.graphics.drawable.Drawable; import android.graphics.Rect; import android.text.Editable; import android.text.NoCopySpan; @@ -122,7 +125,17 @@ public class ToolbarEditText extends CustomEditText @Override public void setText(final CharSequence text, final TextView.BufferType type) { - super.setText(text, type); + final String textString = (text == null) ? "" : text.toString(); + + // If we're on the home or private browsing page, we don't set the "about" url. + final CharSequence finalText; + if (AboutPages.isAboutHome(textString) || AboutPages.isAboutPrivateBrowsing(textString)) { + finalText = ""; + } else { + finalText = text; + } + + super.setText(finalText, type); // Any autocomplete text would have been overwritten, so reset our autocomplete states. resetAutocompleteState(); @@ -160,11 +173,18 @@ public class ToolbarEditText extends CustomEditText } // When on tablet show a magnifying glass in editing mode - if (isActive) { - setCompoundDrawablesWithIntrinsicBounds(R.drawable.search_icon_active, 0, 0, 0); + final int searchDrawableId = R.drawable.search_icon_active; + final Drawable searchDrawable; + if (!isActive) { + searchDrawable = DrawableUtil.tintDrawable(getContext(), searchDrawableId, R.color.placeholder_grey); } else { - setCompoundDrawablesWithIntrinsicBounds(R.drawable.search_icon_inactive, 0, 0, 0); + if (isPrivateMode()) { + searchDrawable = DrawableUtil.tintDrawable(getContext(), searchDrawableId, R.color.tabs_tray_icon_grey); + } else { + searchDrawable = getResources().getDrawable(searchDrawableId); + } } + setCompoundDrawablesWithIntrinsicBounds(searchDrawable, null, null, null); } /** diff --git a/mobile/android/base/toolbar/ToolbarProgressView.java b/mobile/android/base/toolbar/ToolbarProgressView.java index bf45cc788c69..dce9dba91da9 100644 --- a/mobile/android/base/toolbar/ToolbarProgressView.java +++ b/mobile/android/base/toolbar/ToolbarProgressView.java @@ -18,6 +18,7 @@ package org.mozilla.gecko.toolbar; import org.mozilla.gecko.AppConstants.Versions; import org.mozilla.gecko.R; +import org.mozilla.gecko.util.ColorUtils; import org.mozilla.gecko.widget.ThemedImageView; import org.mozilla.gecko.util.WeakReferenceHandler; @@ -70,7 +71,7 @@ public class ToolbarProgressView extends ThemedImageView { mTargetProgress = 0; mPrivateBrowsingColorFilter = new PorterDuffColorFilter( - getResources().getColor(R.color.private_browsing_purple), PorterDuff.Mode.SRC_IN); + ColorUtils.getColor(ctx, R.color.private_browsing_purple), PorterDuff.Mode.SRC_IN); mHandler = new ToolbarProgressHandler(this); } diff --git a/mobile/android/base/updater/UpdateServiceHelper.java b/mobile/android/base/updater/UpdateServiceHelper.java index 9a8f428a2d15..f464146d3f77 100644 --- a/mobile/android/base/updater/UpdateServiceHelper.java +++ b/mobile/android/base/updater/UpdateServiceHelper.java @@ -5,9 +5,9 @@ package org.mozilla.gecko.updater; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.AppConstants; import org.mozilla.gecko.PrefsHelper; -import org.mozilla.gecko.mozglue.RobocopTarget; import org.mozilla.gecko.util.GeckoJarReader; import android.content.Context; diff --git a/mobile/android/base/util/ColorUtils.java b/mobile/android/base/util/ColorUtils.java new file mode 100644 index 000000000000..d13e803aa758 --- /dev/null +++ b/mobile/android/base/util/ColorUtils.java @@ -0,0 +1,26 @@ +/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.gecko.util; + +import android.content.Context; +import android.content.res.Resources; +import android.support.annotation.ColorRes; +import android.support.annotation.NonNull; + +public class ColorUtils { + // TODO: Eventually this functionality should be available in ContextCompat (support library) + @SuppressWarnings("deprecation") + public static int getColor(@NonNull Context context, @ColorRes int color) { + final Resources resources = context.getResources(); + + // TODO: After switching to Android M SDK: Use getColor(color, theme) on Android M+ + // if (AppConstants.Versions.feature23Plus) { + // return resources.getColor(color, context.getTheme()); + // } + + return resources.getColor(color); + } +} diff --git a/mobile/android/base/util/DrawableUtil.java b/mobile/android/base/util/DrawableUtil.java index 386fbe0cdf51..5d0de13b746d 100644 --- a/mobile/android/base/util/DrawableUtil.java +++ b/mobile/android/base/util/DrawableUtil.java @@ -6,6 +6,7 @@ package org.mozilla.gecko.util; import android.content.Context; +import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.support.annotation.ColorRes; import android.support.annotation.DrawableRes; @@ -19,7 +20,14 @@ public class DrawableUtil { @ColorRes final int colorID) { final Drawable icon = DrawableCompat.wrap( ContextCompat.getDrawable(context, drawableID).mutate()); - DrawableCompat.setTint(icon, context.getResources().getColor(colorID)); + DrawableCompat.setTint(icon, ColorUtils.getColor(context, colorID)); return icon; } + + public static Drawable tintDrawableWithStateList(@NonNull final Drawable drawable, + @NonNull final ColorStateList colorList) { + final Drawable wrappedDrawable = DrawableCompat.wrap(drawable.mutate()); + DrawableCompat.setTintList(wrappedDrawable, colorList); + return wrappedDrawable; + } } diff --git a/mobile/android/base/util/EventCallback.java b/mobile/android/base/util/EventCallback.java index 7bd4ad51cbfe..09954266617f 100644 --- a/mobile/android/base/util/EventCallback.java +++ b/mobile/android/base/util/EventCallback.java @@ -1,6 +1,6 @@ package org.mozilla.gecko.util; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; /** * Callback interface for Gecko requests. diff --git a/mobile/android/base/util/FileUtils.java b/mobile/android/base/util/FileUtils.java index 202696338d30..77d6b6651ce8 100644 --- a/mobile/android/base/util/FileUtils.java +++ b/mobile/android/base/util/FileUtils.java @@ -11,7 +11,7 @@ import java.io.IOException; import java.io.FilenameFilter; import java.util.Scanner; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; public class FileUtils { private static final String LOGTAG= "GeckoFileUtils"; diff --git a/mobile/android/base/util/GeckoEventListener.java b/mobile/android/base/util/GeckoEventListener.java index bc78cb5aade3..10336490b704 100644 --- a/mobile/android/base/util/GeckoEventListener.java +++ b/mobile/android/base/util/GeckoEventListener.java @@ -6,7 +6,7 @@ package org.mozilla.gecko.util; import org.json.JSONObject; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; @RobocopTarget public interface GeckoEventListener { diff --git a/mobile/android/base/util/GeckoJarReader.java b/mobile/android/base/util/GeckoJarReader.java index 722f587ea8a6..501d8819af61 100644 --- a/mobile/android/base/util/GeckoJarReader.java +++ b/mobile/android/base/util/GeckoJarReader.java @@ -9,10 +9,10 @@ import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.util.Log; +import org.mozilla.gecko.annotation.RobocopTarget; import org.mozilla.gecko.AppConstants; import org.mozilla.gecko.mozglue.GeckoLoader; import org.mozilla.gecko.mozglue.NativeZip; -import org.mozilla.gecko.mozglue.RobocopTarget; import java.io.BufferedReader; import java.io.File; diff --git a/mobile/android/base/util/GeckoRequest.java b/mobile/android/base/util/GeckoRequest.java index ac32513db2e2..a57ed7f0826d 100644 --- a/mobile/android/base/util/GeckoRequest.java +++ b/mobile/android/base/util/GeckoRequest.java @@ -8,7 +8,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.json.JSONException; import org.json.JSONObject; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; import android.util.Log; diff --git a/mobile/android/base/util/NativeEventListener.java b/mobile/android/base/util/NativeEventListener.java index f5e7bb2d674c..2a1b6e89a8fe 100644 --- a/mobile/android/base/util/NativeEventListener.java +++ b/mobile/android/base/util/NativeEventListener.java @@ -5,7 +5,7 @@ package org.mozilla.gecko.util; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; @RobocopTarget public interface NativeEventListener { diff --git a/mobile/android/base/util/NativeJSContainer.java b/mobile/android/base/util/NativeJSContainer.java index 0c939cadea30..ac092ecc83d4 100644 --- a/mobile/android/base/util/NativeJSContainer.java +++ b/mobile/android/base/util/NativeJSContainer.java @@ -6,7 +6,6 @@ package org.mozilla.gecko.util; import org.mozilla.gecko.annotation.WrapForJNI; -import org.mozilla.gecko.mozglue.JNITarget; /** * NativeJSContainer is a wrapper around the SpiderMonkey JSAPI to make it possible to diff --git a/mobile/android/base/util/NativeJSObject.java b/mobile/android/base/util/NativeJSObject.java index ad5b645d6480..0adce638ce16 100644 --- a/mobile/android/base/util/NativeJSObject.java +++ b/mobile/android/base/util/NativeJSObject.java @@ -5,9 +5,9 @@ package org.mozilla.gecko.util; +import org.mozilla.gecko.annotation.JNITarget; import org.mozilla.gecko.annotation.WrapForJNI; import org.mozilla.gecko.mozglue.JNIObject; -import org.mozilla.gecko.mozglue.JNITarget; import android.os.Bundle; diff --git a/mobile/android/base/util/ThreadUtils.java b/mobile/android/base/util/ThreadUtils.java index 64681f23d755..884a56dc4dcd 100644 --- a/mobile/android/base/util/ThreadUtils.java +++ b/mobile/android/base/util/ThreadUtils.java @@ -5,7 +5,7 @@ package org.mozilla.gecko.util; -import org.mozilla.gecko.mozglue.RobocopTarget; +import org.mozilla.gecko.annotation.RobocopTarget; import java.util.Map; diff --git a/mobile/android/base/widget/ContentSecurityDoorHanger.java b/mobile/android/base/widget/ContentSecurityDoorHanger.java index 2c0c2e12e531..d888b1828f3f 100644 --- a/mobile/android/base/widget/ContentSecurityDoorHanger.java +++ b/mobile/android/base/widget/ContentSecurityDoorHanger.java @@ -16,6 +16,7 @@ import org.json.JSONObject; import android.content.Context; import android.view.View; import org.mozilla.gecko.toolbar.SiteIdentityPopup; +import org.mozilla.gecko.util.ColorUtils; public class ContentSecurityDoorHanger extends DoorHanger { private static final String LOGTAG = "GeckoSecurityDoorHanger"; @@ -80,11 +81,11 @@ public class ContentSecurityDoorHanger extends DoorHanger { if (enabled) { mMessage.setText(R.string.doorhanger_tracking_message_enabled); mSecurityState.setText(R.string.doorhanger_tracking_state_enabled); - mSecurityState.setTextColor(getResources().getColor(R.color.affirmative_green)); + mSecurityState.setTextColor(ColorUtils.getColor(getContext(), R.color.affirmative_green)); } else { mMessage.setText(R.string.doorhanger_tracking_message_disabled); mSecurityState.setText(R.string.doorhanger_tracking_state_disabled); - mSecurityState.setTextColor(getResources().getColor(R.color.rejection_red)); + mSecurityState.setTextColor(ColorUtils.getColor(getContext(), R.color.rejection_red)); } mMessage.setVisibility(VISIBLE); mSecurityState.setVisibility(VISIBLE); diff --git a/mobile/android/base/widget/DefaultDoorHanger.java b/mobile/android/base/widget/DefaultDoorHanger.java index 88ea3ac64256..23bbbbe574e2 100644 --- a/mobile/android/base/widget/DefaultDoorHanger.java +++ b/mobile/android/base/widget/DefaultDoorHanger.java @@ -12,6 +12,7 @@ import android.widget.Button; import android.widget.TextView; import org.mozilla.gecko.R; import org.mozilla.gecko.prompts.PromptInput; +import org.mozilla.gecko.util.ColorUtils; import org.json.JSONArray; import org.json.JSONException; @@ -41,7 +42,7 @@ public class DefaultDoorHanger extends DoorHanger { mMessage = (TextView) findViewById(R.id.doorhanger_message); if (sSpinnerTextColor == -1) { - sSpinnerTextColor = mResources.getColor(R.color.text_color_primary_disable_only); + sSpinnerTextColor = ColorUtils.getColor(context, R.color.text_color_primary_disable_only); } switch (mType) { diff --git a/mobile/android/base/widget/DoorHanger.java b/mobile/android/base/widget/DoorHanger.java index 91f8c906ae29..0d11a1116825 100644 --- a/mobile/android/base/widget/DoorHanger.java +++ b/mobile/android/base/widget/DoorHanger.java @@ -19,6 +19,7 @@ import android.widget.TextView; import org.json.JSONObject; import org.mozilla.gecko.R; import org.mozilla.gecko.Tabs; +import org.mozilla.gecko.util.ColorUtils; public abstract class DoorHanger extends LinearLayout { @@ -90,7 +91,7 @@ public abstract class DoorHanger extends LinearLayout { mPositiveButton = (Button) findViewById(R.id.doorhanger_button_positive); mOnButtonClickListener = config.getButtonClickListener(); - mDividerColor = mResources.getColor(R.color.divider_light); + mDividerColor = ColorUtils.getColor(context, R.color.divider_light); final ViewStub contentStub = (ViewStub) findViewById(R.id.content); contentStub.setLayoutResource(getContentResource()); diff --git a/mobile/android/base/widget/GeckoSwipeRefreshLayout.java b/mobile/android/base/widget/GeckoSwipeRefreshLayout.java index 048cc091e56c..1536c4c2eb2f 100644 --- a/mobile/android/base/widget/GeckoSwipeRefreshLayout.java +++ b/mobile/android/base/widget/GeckoSwipeRefreshLayout.java @@ -17,6 +17,7 @@ package org.mozilla.gecko.widget; import org.mozilla.gecko.AppConstants.Versions; +import org.mozilla.gecko.util.ColorUtils; import android.content.Context; import android.content.res.Resources; @@ -273,11 +274,11 @@ public class GeckoSwipeRefreshLayout extends ViewGroup { */ public void setColorScheme(int colorRes1, int colorRes2, int colorRes3, int colorRes4) { ensureTarget(); - final Resources res = getResources(); - final int color1 = res.getColor(colorRes1); - final int color2 = res.getColor(colorRes2); - final int color3 = res.getColor(colorRes3); - final int color4 = res.getColor(colorRes4); + final Context context = getContext(); + final int color1 = ColorUtils.getColor(context, colorRes1); + final int color2 = ColorUtils.getColor(context, colorRes2); + final int color3 = ColorUtils.getColor(context, colorRes3); + final int color4 = ColorUtils.getColor(context, colorRes4); mProgressBar.setColorScheme(color1, color2, color3,color4); } diff --git a/mobile/android/base/widget/IconTabWidget.java b/mobile/android/base/widget/IconTabWidget.java index 579f819f4de6..71987bf8c9f9 100644 --- a/mobile/android/base/widget/IconTabWidget.java +++ b/mobile/android/base/widget/IconTabWidget.java @@ -38,7 +38,7 @@ public class IconTabWidget extends TabWidget { } } - public void addTab(int imageResId, int stringResId) { + public View addTab(final int imageResId, final int stringResId) { View button = LayoutInflater.from(getContext()).inflate(mButtonLayoutId, this, false); if (mIsIcon) { ((ImageButton) button).setImageResource(imageResId); @@ -50,6 +50,7 @@ public class IconTabWidget extends TabWidget { addView(button); button.setOnClickListener(new TabClickListener(getTabCount() - 1)); button.setOnFocusChangeListener(this); + return button; } public void setTabSelectionListener(OnTabChangedListener listener) { diff --git a/mobile/android/base/widget/TabThumbnailWrapper.java b/mobile/android/base/widget/TabThumbnailWrapper.java index 088dae92c735..928a61606fd1 100644 --- a/mobile/android/base/widget/TabThumbnailWrapper.java +++ b/mobile/android/base/widget/TabThumbnailWrapper.java @@ -2,11 +2,10 @@ package org.mozilla.gecko.widget; import android.content.Context; import android.util.AttributeSet; -import android.widget.RelativeLayout; import org.mozilla.gecko.R; -public class TabThumbnailWrapper extends RelativeLayout { +public class TabThumbnailWrapper extends ThemedRelativeLayout { private boolean mRecording; private static final int[] STATE_RECORDING = { R.attr.state_recording }; @@ -18,10 +17,6 @@ public class TabThumbnailWrapper extends RelativeLayout { super(context, attrs); } - public TabThumbnailWrapper(Context context) { - super(context); - } - @Override public int[] onCreateDrawableState(int extraSpace) { final int[] drawableState = super.onCreateDrawableState(extraSpace + 1); diff --git a/mobile/android/base/widget/ThemedEditText.java b/mobile/android/base/widget/ThemedEditText.java index 586a59c383b1..3d9f059dbd75 100644 --- a/mobile/android/base/widget/ThemedEditText.java +++ b/mobile/android/base/widget/ThemedEditText.java @@ -9,6 +9,7 @@ package org.mozilla.gecko.widget; import org.mozilla.gecko.GeckoApplication; import org.mozilla.gecko.lwt.LightweightTheme; import org.mozilla.gecko.R; +import org.mozilla.gecko.util.ColorUtils; import android.content.Context; import android.content.res.TypedArray; @@ -111,6 +112,7 @@ public class ThemedEditText extends android.widget.EditText if (mIsPrivate != isPrivate) { mIsPrivate = isPrivate; refreshDrawableState(); + invalidate(); } } @@ -127,6 +129,7 @@ public class ThemedEditText extends android.widget.EditText } refreshDrawableState(); + invalidate(); } } @@ -135,6 +138,7 @@ public class ThemedEditText extends android.widget.EditText mIsLight = false; mIsDark = false; refreshDrawableState(); + invalidate(); } } @@ -154,7 +158,7 @@ public class ThemedEditText extends android.widget.EditText } public ColorDrawable getColorDrawable(int id) { - return new ColorDrawable(getResources().getColor(id)); + return new ColorDrawable(ColorUtils.getColor(getContext(), id)); } protected LightweightTheme getTheme() { diff --git a/mobile/android/base/widget/ThemedImageButton.java b/mobile/android/base/widget/ThemedImageButton.java index 0b0b9bcd7860..4397befe7bd8 100644 --- a/mobile/android/base/widget/ThemedImageButton.java +++ b/mobile/android/base/widget/ThemedImageButton.java @@ -9,6 +9,7 @@ package org.mozilla.gecko.widget; import org.mozilla.gecko.GeckoApplication; import org.mozilla.gecko.lwt.LightweightTheme; import org.mozilla.gecko.R; +import org.mozilla.gecko.util.ColorUtils; import android.content.Context; import android.content.res.TypedArray; @@ -111,6 +112,7 @@ public class ThemedImageButton extends android.widget.ImageButton if (mIsPrivate != isPrivate) { mIsPrivate = isPrivate; refreshDrawableState(); + invalidate(); } } @@ -127,6 +129,7 @@ public class ThemedImageButton extends android.widget.ImageButton } refreshDrawableState(); + invalidate(); } } @@ -135,6 +138,7 @@ public class ThemedImageButton extends android.widget.ImageButton mIsLight = false; mIsDark = false; refreshDrawableState(); + invalidate(); } } @@ -154,7 +158,7 @@ public class ThemedImageButton extends android.widget.ImageButton } public ColorDrawable getColorDrawable(int id) { - return new ColorDrawable(getResources().getColor(id)); + return new ColorDrawable(ColorUtils.getColor(getContext(), id)); } protected LightweightTheme getTheme() { diff --git a/mobile/android/base/widget/ThemedImageView.java b/mobile/android/base/widget/ThemedImageView.java index 7227247b8b1b..26788af76386 100644 --- a/mobile/android/base/widget/ThemedImageView.java +++ b/mobile/android/base/widget/ThemedImageView.java @@ -9,6 +9,7 @@ package org.mozilla.gecko.widget; import org.mozilla.gecko.GeckoApplication; import org.mozilla.gecko.lwt.LightweightTheme; import org.mozilla.gecko.R; +import org.mozilla.gecko.util.ColorUtils; import android.content.Context; import android.content.res.TypedArray; @@ -111,6 +112,7 @@ public class ThemedImageView extends android.widget.ImageView if (mIsPrivate != isPrivate) { mIsPrivate = isPrivate; refreshDrawableState(); + invalidate(); } } @@ -127,6 +129,7 @@ public class ThemedImageView extends android.widget.ImageView } refreshDrawableState(); + invalidate(); } } @@ -135,6 +138,7 @@ public class ThemedImageView extends android.widget.ImageView mIsLight = false; mIsDark = false; refreshDrawableState(); + invalidate(); } } @@ -154,7 +158,7 @@ public class ThemedImageView extends android.widget.ImageView } public ColorDrawable getColorDrawable(int id) { - return new ColorDrawable(getResources().getColor(id)); + return new ColorDrawable(ColorUtils.getColor(getContext(), id)); } protected LightweightTheme getTheme() { diff --git a/mobile/android/base/widget/ThemedLinearLayout.java b/mobile/android/base/widget/ThemedLinearLayout.java index c04de75788ea..471c9bd70bf4 100644 --- a/mobile/android/base/widget/ThemedLinearLayout.java +++ b/mobile/android/base/widget/ThemedLinearLayout.java @@ -9,6 +9,7 @@ package org.mozilla.gecko.widget; import org.mozilla.gecko.GeckoApplication; import org.mozilla.gecko.lwt.LightweightTheme; import org.mozilla.gecko.R; +import org.mozilla.gecko.util.ColorUtils; import android.content.Context; import android.content.res.TypedArray; @@ -106,6 +107,7 @@ public class ThemedLinearLayout extends android.widget.LinearLayout if (mIsPrivate != isPrivate) { mIsPrivate = isPrivate; refreshDrawableState(); + invalidate(); } } @@ -122,6 +124,7 @@ public class ThemedLinearLayout extends android.widget.LinearLayout } refreshDrawableState(); + invalidate(); } } @@ -130,6 +133,7 @@ public class ThemedLinearLayout extends android.widget.LinearLayout mIsLight = false; mIsDark = false; refreshDrawableState(); + invalidate(); } } @@ -149,7 +153,7 @@ public class ThemedLinearLayout extends android.widget.LinearLayout } public ColorDrawable getColorDrawable(int id) { - return new ColorDrawable(getResources().getColor(id)); + return new ColorDrawable(ColorUtils.getColor(getContext(), id)); } protected LightweightTheme getTheme() { diff --git a/mobile/android/base/widget/ThemedRelativeLayout.java b/mobile/android/base/widget/ThemedRelativeLayout.java index db2991bbfb6c..394e754c735c 100644 --- a/mobile/android/base/widget/ThemedRelativeLayout.java +++ b/mobile/android/base/widget/ThemedRelativeLayout.java @@ -9,6 +9,7 @@ package org.mozilla.gecko.widget; import org.mozilla.gecko.GeckoApplication; import org.mozilla.gecko.lwt.LightweightTheme; import org.mozilla.gecko.R; +import org.mozilla.gecko.util.ColorUtils; import android.content.Context; import android.content.res.TypedArray; @@ -111,6 +112,7 @@ public class ThemedRelativeLayout extends android.widget.RelativeLayout if (mIsPrivate != isPrivate) { mIsPrivate = isPrivate; refreshDrawableState(); + invalidate(); } } @@ -127,6 +129,7 @@ public class ThemedRelativeLayout extends android.widget.RelativeLayout } refreshDrawableState(); + invalidate(); } } @@ -135,6 +138,7 @@ public class ThemedRelativeLayout extends android.widget.RelativeLayout mIsLight = false; mIsDark = false; refreshDrawableState(); + invalidate(); } } @@ -154,7 +158,7 @@ public class ThemedRelativeLayout extends android.widget.RelativeLayout } public ColorDrawable getColorDrawable(int id) { - return new ColorDrawable(getResources().getColor(id)); + return new ColorDrawable(ColorUtils.getColor(getContext(), id)); } protected LightweightTheme getTheme() { diff --git a/mobile/android/base/widget/ThemedTextSwitcher.java b/mobile/android/base/widget/ThemedTextSwitcher.java index 0bba303889df..82cc16bb2d92 100644 --- a/mobile/android/base/widget/ThemedTextSwitcher.java +++ b/mobile/android/base/widget/ThemedTextSwitcher.java @@ -9,6 +9,7 @@ package org.mozilla.gecko.widget; import org.mozilla.gecko.GeckoApplication; import org.mozilla.gecko.lwt.LightweightTheme; import org.mozilla.gecko.R; +import org.mozilla.gecko.util.ColorUtils; import android.content.Context; import android.content.res.TypedArray; @@ -106,6 +107,7 @@ public class ThemedTextSwitcher extends android.widget.TextSwitcher if (mIsPrivate != isPrivate) { mIsPrivate = isPrivate; refreshDrawableState(); + invalidate(); } } @@ -122,6 +124,7 @@ public class ThemedTextSwitcher extends android.widget.TextSwitcher } refreshDrawableState(); + invalidate(); } } @@ -130,6 +133,7 @@ public class ThemedTextSwitcher extends android.widget.TextSwitcher mIsLight = false; mIsDark = false; refreshDrawableState(); + invalidate(); } } @@ -149,7 +153,7 @@ public class ThemedTextSwitcher extends android.widget.TextSwitcher } public ColorDrawable getColorDrawable(int id) { - return new ColorDrawable(getResources().getColor(id)); + return new ColorDrawable(ColorUtils.getColor(getContext(), id)); } protected LightweightTheme getTheme() { diff --git a/mobile/android/base/widget/ThemedTextView.java b/mobile/android/base/widget/ThemedTextView.java index 024c75b25a03..2adc9b348c2d 100644 --- a/mobile/android/base/widget/ThemedTextView.java +++ b/mobile/android/base/widget/ThemedTextView.java @@ -9,6 +9,7 @@ package org.mozilla.gecko.widget; import org.mozilla.gecko.GeckoApplication; import org.mozilla.gecko.lwt.LightweightTheme; import org.mozilla.gecko.R; +import org.mozilla.gecko.util.ColorUtils; import android.content.Context; import android.content.res.TypedArray; @@ -111,6 +112,7 @@ public class ThemedTextView extends android.widget.TextView if (mIsPrivate != isPrivate) { mIsPrivate = isPrivate; refreshDrawableState(); + invalidate(); } } @@ -127,6 +129,7 @@ public class ThemedTextView extends android.widget.TextView } refreshDrawableState(); + invalidate(); } } @@ -135,6 +138,7 @@ public class ThemedTextView extends android.widget.TextView mIsLight = false; mIsDark = false; refreshDrawableState(); + invalidate(); } } @@ -154,7 +158,7 @@ public class ThemedTextView extends android.widget.TextView } public ColorDrawable getColorDrawable(int id) { - return new ColorDrawable(getResources().getColor(id)); + return new ColorDrawable(ColorUtils.getColor(getContext(), id)); } protected LightweightTheme getTheme() { diff --git a/mobile/android/base/widget/ThemedView.java b/mobile/android/base/widget/ThemedView.java index 9cc88c3114ab..090036cb6f85 100644 --- a/mobile/android/base/widget/ThemedView.java +++ b/mobile/android/base/widget/ThemedView.java @@ -9,6 +9,7 @@ package org.mozilla.gecko.widget; import org.mozilla.gecko.GeckoApplication; import org.mozilla.gecko.lwt.LightweightTheme; import org.mozilla.gecko.R; +import org.mozilla.gecko.util.ColorUtils; import android.content.Context; import android.content.res.TypedArray; @@ -111,6 +112,7 @@ public class ThemedView extends android.view.View if (mIsPrivate != isPrivate) { mIsPrivate = isPrivate; refreshDrawableState(); + invalidate(); } } @@ -127,6 +129,7 @@ public class ThemedView extends android.view.View } refreshDrawableState(); + invalidate(); } } @@ -135,6 +138,7 @@ public class ThemedView extends android.view.View mIsLight = false; mIsDark = false; refreshDrawableState(); + invalidate(); } } @@ -154,7 +158,7 @@ public class ThemedView extends android.view.View } public ColorDrawable getColorDrawable(int id) { - return new ColorDrawable(getResources().getColor(id)); + return new ColorDrawable(ColorUtils.getColor(getContext(), id)); } protected LightweightTheme getTheme() { diff --git a/mobile/android/base/widget/ThemedView.java.frag b/mobile/android/base/widget/ThemedView.java.frag index 7ffb1dcee0e8..077f9871a38d 100644 --- a/mobile/android/base/widget/ThemedView.java.frag +++ b/mobile/android/base/widget/ThemedView.java.frag @@ -114,6 +114,7 @@ public class Themed@VIEW_NAME_SUFFIX@ extends @BASE_TYPE@ if (mIsPrivate != isPrivate) { mIsPrivate = isPrivate; refreshDrawableState(); + invalidate(); } } @@ -130,6 +131,7 @@ public class Themed@VIEW_NAME_SUFFIX@ extends @BASE_TYPE@ } refreshDrawableState(); + invalidate(); } } @@ -138,6 +140,7 @@ public class Themed@VIEW_NAME_SUFFIX@ extends @BASE_TYPE@ mIsLight = false; mIsDark = false; refreshDrawableState(); + invalidate(); } } diff --git a/mobile/android/config/proguard/proguard.cfg b/mobile/android/config/proguard/proguard.cfg index 466ea1a6a16f..c6b15f447120 100644 --- a/mobile/android/config/proguard/proguard.cfg +++ b/mobile/android/config/proguard/proguard.cfg @@ -118,19 +118,19 @@ # Keep miscellaneous targets. # Keep the annotation. --keep @interface org.mozilla.gecko.mozglue.JNITarget +-keep @interface org.mozilla.gecko.annotation.JNITarget # Keep classes tagged with the annotation. --keep @org.mozilla.gecko.mozglue.JNITarget class * +-keep @org.mozilla.gecko.annotation.JNITarget class * # Keep all members of an annotated class. --keepclassmembers @org.mozilla.gecko.mozglue.JNITarget class * { +-keepclassmembers @org.mozilla.gecko.annotation.JNITarget class * { *; } # Keep annotated members of any class. -keepclassmembers class * { - @org.mozilla.gecko.mozglue.JNITarget *; + @org.mozilla.gecko.annotation.JNITarget *; } # Keep classes which contain at least one annotated element. Split over two directives @@ -138,44 +138,44 @@ # doesn't combine well with the '*' wildcard" (And, indeed, using it causes things to # be deleted that we want to keep.) -keepclasseswithmembers class * { - @org.mozilla.gecko.mozglue.JNITarget ; + @org.mozilla.gecko.annotation.JNITarget ; } -keepclasseswithmembers class * { - @org.mozilla.gecko.mozglue.JNITarget ; + @org.mozilla.gecko.annotation.JNITarget ; } # Keep Robocop targets. TODO: Can omit these from release builds. Also, Bug 916507. # Same formula as above... --keep @interface org.mozilla.gecko.mozglue.RobocopTarget --keep @org.mozilla.gecko.mozglue.RobocopTarget class * +-keep @interface org.mozilla.gecko.annotation.RobocopTarget +-keep @org.mozilla.gecko.annotation.RobocopTarget class * -keepclassmembers class * { - @org.mozilla.gecko.mozglue.RobocopTarget *; + @org.mozilla.gecko.annotation.RobocopTarget *; } --keepclassmembers @org.mozilla.gecko.mozglue.RobocopTarget class * { +-keepclassmembers @org.mozilla.gecko.annotation.RobocopTarget class * { *; } -keepclasseswithmembers class * { - @org.mozilla.gecko.mozglue.RobocopTarget ; + @org.mozilla.gecko.annotation.RobocopTarget ; } -keepclasseswithmembers class * { - @org.mozilla.gecko.mozglue.RobocopTarget ; + @org.mozilla.gecko.annotation.RobocopTarget ; } # Keep WebRTC targets. --keep @interface org.mozilla.gecko.mozglue.WebRTCJNITarget --keep @org.mozilla.gecko.mozglue.WebRTCJNITarget class * +-keep @interface org.mozilla.gecko.annotation.WebRTCJNITarget +-keep @org.mozilla.gecko.annotation.WebRTCJNITarget class * -keepclassmembers class * { - @org.mozilla.gecko.mozglue.WebRTCJNITarget *; + @org.mozilla.gecko.annotation.WebRTCJNITarget *; } --keepclassmembers @org.mozilla.gecko.mozglue.WebRTCJNITarget class * { +-keepclassmembers @org.mozilla.gecko.annotation.WebRTCJNITarget class * { *; } -keepclasseswithmembers class * { - @org.mozilla.gecko.mozglue.WebRTCJNITarget ; + @org.mozilla.gecko.annotation.WebRTCJNITarget ; } -keepclasseswithmembers class * { - @org.mozilla.gecko.mozglue.WebRTCJNITarget ; + @org.mozilla.gecko.annotation.WebRTCJNITarget ; } # Keep generator-targeted entry points. @@ -198,7 +198,7 @@ -keep class **.R$* -# Keep classes, and all their contents, compiled before mozglue.RobocopTarget. +# Keep classes, and all their contents, compiled before annotation.RobocopTarget. -keep class org.mozilla.gecko.AppConstants { *; } diff --git a/mobile/android/search/java/org/mozilla/search/PostSearchFragment.java b/mobile/android/search/java/org/mozilla/search/PostSearchFragment.java index de9cff67e0bf..f287eeb01e04 100644 --- a/mobile/android/search/java/org/mozilla/search/PostSearchFragment.java +++ b/mobile/android/search/java/org/mozilla/search/PostSearchFragment.java @@ -12,6 +12,7 @@ import org.mozilla.gecko.AppConstants; import org.mozilla.gecko.R; import org.mozilla.gecko.Telemetry; import org.mozilla.gecko.TelemetryContract; +import org.mozilla.gecko.util.ColorUtils; import org.mozilla.search.providers.SearchEngine; import android.annotation.SuppressLint; @@ -164,7 +165,7 @@ public class PostSearchFragment extends Fragment { final TextView message = (TextView) errorView.findViewById(R.id.empty_message); message.setText(R.string.network_error_message); - message.setTextColor(getResources().getColor(R.color.network_error_link)); + message.setTextColor(ColorUtils.getColor(view.getContext(), R.color.network_error_link)); message.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/mobile/android/search/java/org/mozilla/search/autocomplete/SuggestionsFragment.java b/mobile/android/search/java/org/mozilla/search/autocomplete/SuggestionsFragment.java index 436ae5d4a2a5..63fb37e53905 100644 --- a/mobile/android/search/java/org/mozilla/search/autocomplete/SuggestionsFragment.java +++ b/mobile/android/search/java/org/mozilla/search/autocomplete/SuggestionsFragment.java @@ -11,6 +11,7 @@ import org.mozilla.gecko.R; import org.mozilla.gecko.SuggestClient; import org.mozilla.gecko.Telemetry; import org.mozilla.gecko.TelemetryContract; +import org.mozilla.gecko.util.ColorUtils; import org.mozilla.search.AcceptsSearchQuery; import org.mozilla.search.AcceptsSearchQuery.SuggestionAnimation; import org.mozilla.search.providers.SearchEngine; @@ -212,7 +213,7 @@ public class SuggestionsFragment extends Fragment { this.suggestions = null; // Color of search term match in search suggestion - suggestionHighlightColor = context.getResources().getColor(R.color.suggestion_highlight); + suggestionHighlightColor = ColorUtils.getColor(context, R.color.suggestion_highlight); } @Override diff --git a/mobile/android/tests/browser/robocop/BaseTest.java b/mobile/android/tests/browser/robocop/BaseTest.java index 9521694c2288..f52138a12bba 100644 --- a/mobile/android/tests/browser/robocop/BaseTest.java +++ b/mobile/android/tests/browser/robocop/BaseTest.java @@ -184,7 +184,7 @@ abstract class BaseTest extends BaseRobocopTest { // Send the keys for the URL we want to enter mSolo.clearEditText(urlEditView); - mSolo.enterText(urlEditView, url); + mSolo.typeText(urlEditView, url); // Get the URL text from the URL bar EditText view final String urlBarText = urlEditView.getText().toString(); diff --git a/mobile/android/tests/browser/robocop/testInputUrlBar.java b/mobile/android/tests/browser/robocop/testInputUrlBar.java index c4cd8a412e7a..c12ccef98276 100644 --- a/mobile/android/tests/browser/robocop/testInputUrlBar.java +++ b/mobile/android/tests/browser/robocop/testInputUrlBar.java @@ -23,7 +23,7 @@ public final class testInputUrlBar extends BaseTest { blockForGeckoReady(); startEditingMode(); - assertUrlBarText(mStringHelper.ABOUT_HOME_URL); + assertUrlBarText(""); // Avoid any auto domain completion by using a prefix that matches // nothing, including about: pages @@ -97,7 +97,7 @@ public final class testInputUrlBar extends BaseTest { // URL bar should have forgotten about "uv" text. startEditingMode(); - assertUrlBarText(mStringHelper.ABOUT_HOME_URL); + assertUrlBarText(""); int width = mDriver.getGeckoWidth() / 2; int y = mDriver.getGeckoHeight() / 2; diff --git a/services/sync/tests/unit/head_http_server.js b/services/sync/tests/unit/head_http_server.js index c917c4988c2f..82fb89e90347 100644 --- a/services/sync/tests/unit/head_http_server.js +++ b/services/sync/tests/unit/head_http_server.js @@ -545,13 +545,13 @@ SyncServer.prototype = { * Start the SyncServer's underlying HTTP server. * * @param port - * The numeric port on which to start. A falsy value implies the - * default, a randomly chosen port. + * The numeric port on which to start. -1 implies the default, a + * randomly chosen port. * @param cb * A callback function (of no arguments) which is invoked after * startup. */ - start: function start(port, cb) { + start: function start(port = -1, cb) { if (this.started) { this._log.warn("Warning: server already started on " + this.port); return; diff --git a/toolkit/content/browser-content.js b/toolkit/content/browser-content.js index f6436832d0f4..abbecfc1db25 100644 --- a/toolkit/content/browser-content.js +++ b/toolkit/content/browser-content.js @@ -725,6 +725,30 @@ let AudioPlaybackListener = { }; AudioPlaybackListener.init(); +addMessageListener("Browser:PurgeSessionHistory", function BrowserPurgeHistory() { + let sessionHistory = docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory; + if (!sessionHistory) { + return; + } + + // place the entry at current index at the end of the history list, so it won't get removed + if (sessionHistory.index < sessionHistory.count - 1) { + let indexEntry = sessionHistory.getEntryAtIndex(sessionHistory.index, false); + sessionHistory.QueryInterface(Components.interfaces.nsISHistoryInternal); + indexEntry.QueryInterface(Components.interfaces.nsISHEntry); + sessionHistory.addEntry(indexEntry, true); + } + + let purge = sessionHistory.count; + if (global.content.location.href != "about:blank") { + --purge; // Don't remove the page the user's staring at from shistory + } + + if (purge > 0) { + sessionHistory.PurgeHistory(purge); + } +}); + let ViewSelectionSource = { init: function () { addMessageListener("ViewSource:GetSelection", this); diff --git a/toolkit/content/widgets/browser.xml b/toolkit/content/widgets/browser.xml index 61d947477348..960645f76f82 100644 --- a/toolkit/content/widgets/browser.xml +++ b/toolkit/content/widgets/browser.xml @@ -871,7 +871,10 @@ + we are removed from a tabbrowser. This will be explicitly called by tabbrowser. + + Note: this function is overriden in remote-browser.xml, so any clean-up that + also applies to browser.isRemoteBrowser = true must be duplicated there. --> + + - var purge = this.sessionHistory.count; - if (this.currentURI != "about:blank") - --purge; // Don't remove the page the user's staring at from shistory - - if (purge > 0) - this.sessionHistory.PurgeHistory(purge); + + + diff --git a/toolkit/content/widgets/remote-browser.xml b/toolkit/content/widgets/remote-browser.xml index 2d26842e390e..86d4eae2f291 100644 --- a/toolkit/content/widgets/remote-browser.xml +++ b/toolkit/content/widgets/remote-browser.xml @@ -261,6 +261,10 @@ this.messageManager.loadFrameScript("chrome://global/content/select-child.js", true); } + if (!this.hasAttribute("disablehistory")) { + Services.obs.addObserver(this, "browser:purge-session-history", false) + } + jsm = "resource://gre/modules/RemoteController.jsm"; let RemoteController = Components.utils.import(jsm, {}).RemoteController; this._controller = new RemoteController(this); @@ -275,7 +279,9 @@ + we are removed from a tabbrowser. This will be explicitly called by tabbrowser. + + Note: This overrides the destroy() method from browser.xml. --> @@ -389,6 +403,15 @@ + + + + + diff --git a/toolkit/devtools/gcli/commands/cookie.js b/toolkit/devtools/gcli/commands/cookie.js index 11efa87f68ef..e657d7dfadfc 100644 --- a/toolkit/devtools/gcli/commands/cookie.js +++ b/toolkit/devtools/gcli/commands/cookie.js @@ -21,7 +21,7 @@ XPCOMUtils.defineLazyGetter(this, "cookieMgr", function() { */ function sanitizeHost(host) { if (host == null || host == "") { - throw new Error(gcli.lookup("cookieListOutNonePage")); + throw new Error(l10n.lookup("cookieListOutNonePage")); } return host.split(':')[0]; } diff --git a/toolkit/devtools/server/actors/inspector.js b/toolkit/devtools/server/actors/inspector.js index 0a4e60df52e3..2933b95f1111 100644 --- a/toolkit/devtools/server/actors/inspector.js +++ b/toolkit/devtools/server/actors/inspector.js @@ -1298,7 +1298,13 @@ var WalkerActor = protocol.ActorClass({ form: function() { return { actor: this.actorID, - root: this.rootNode.form() + root: this.rootNode.form(), + traits: { + // FF42+ Inspector starts managing the Walker, while the inspector also + // starts cleaning itself up automatically on client disconnection. + // So that there is no need to manually release the walker anymore. + autoReleased: true + } } }, @@ -3108,6 +3114,8 @@ var WalkerFront = exports.WalkerFront = protocol.FrontClass(WalkerActor, { this.actorID = json.actor; this.rootNode = types.getType("domnode").read(json.root, this); this._rootNodeDeferred.resolve(this.rootNode); + // FF42+ the actor starts exposing traits + this.traits = json.traits || {}; }, /** @@ -3522,6 +3530,7 @@ var InspectorActor = exports.InspectorActor = protocol.ActorClass({ let tabActor = this.tabActor; window.removeEventListener("DOMContentLoaded", domReady, true); this.walker = WalkerActor(this.conn, tabActor, options); + this.manage(this.walker); events.once(this.walker, "destroyed", () => { this._walkerPromise = null; this._pageStylePromise = null; diff --git a/toolkit/themes/faststripe/global/menu.css b/toolkit/themes/faststripe/global/menu.css index 434c1322032a..1fe132c2de98 100644 --- a/toolkit/themes/faststripe/global/menu.css +++ b/toolkit/themes/faststripe/global/menu.css @@ -70,8 +70,7 @@ menuitem.spell-suggestion { -moz-margin-end: 1.35em !important; } -.menu-iconic-left, -.menu-iconic-right { +.menu-iconic-left { min-width: 1.45em; } @@ -156,11 +155,8 @@ menulist > menupopup > menu { } menulist > menupopup > menuitem > .menu-iconic-left, -menulist > menupopup > menu > .menu-iconic-left, -menulist > menupopup > menuitem > .menu-iconic-right, -menulist > menupopup > menu > .menu-iconic-right { +menulist > menupopup > menu > .menu-iconic-left { display: none; - padding-top: 0px; } menulist > menupopup > menuitem > label, diff --git a/toolkit/themes/linux/global/menu.css b/toolkit/themes/linux/global/menu.css index c2c779b5a4fb..aab929e9c6c6 100644 --- a/toolkit/themes/linux/global/menu.css +++ b/toolkit/themes/linux/global/menu.css @@ -160,10 +160,7 @@ menucaption > .menu-iconic-text { menulist > menupopup > menuitem > .menu-iconic-left, menulist > menupopup > menucaption > .menu-iconic-left, -menulist > menupopup > menu > .menu-iconic-left, -menulist > menupopup > menuitem > .menu-iconic-right, -menulist > menupopup > menucaption > .menu-iconic-right, -menulist > menupopup > menu > .menu-iconic-right { +menulist > menupopup > menu > .menu-iconic-left { display: none; } diff --git a/toolkit/themes/osx/global/menu.css b/toolkit/themes/osx/global/menu.css index a42c26e93b71..2e6a696ee4b8 100644 --- a/toolkit/themes/osx/global/menu.css +++ b/toolkit/themes/osx/global/menu.css @@ -63,7 +63,6 @@ menucaption > .menu-iconic-text { .menuitem-iconic, .menu-iconic, menuitem[image], -menuitem[endimage], menuitem[src] { /* 2px higher than those without icons */ padding-top: 1px; @@ -168,8 +167,7 @@ menulist[editable="true"] > menupopup > menucaption { -moz-appearance: none; } -menulist[editable="true"] > menupopup > :-moz-any(menuitem, menucaption) > .menu-iconic-left, -menulist[editable="true"] > menupopup > :-moz-any(menuitem, menucaption) > .menu-iconic-right { +menulist[editable="true"] > menupopup > :-moz-any(menuitem, menucaption) > .menu-iconic-left { display: none; } diff --git a/toolkit/themes/windows/global/menu.css b/toolkit/themes/windows/global/menu.css index c657e5f6ac01..eedc03c2f5ec 100644 --- a/toolkit/themes/windows/global/menu.css +++ b/toolkit/themes/windows/global/menu.css @@ -92,8 +92,7 @@ menucaption > .menu-iconic-text { -moz-margin-end: 1.35em !important; } -.menu-iconic-left, -.menu-iconic-right { +.menu-iconic-left { min-width: 1.45em; } @@ -222,12 +221,8 @@ menulist > menupopup > menu[_moz-menuactive="true"] { menulist > menupopup > menuitem > .menu-iconic-left, menulist > menupopup > menucaption > .menu-iconic-left, -menulist > menupopup > menu > .menu-iconic-left, -menulist > menupopup > menuitem > .menu-iconic-right, -menulist > menupopup > menucaption > .menu-iconic-right, -menulist > menupopup > menu > .menu-iconic-right { +menulist > menupopup > menu > .menu-iconic-left { display: none; - padding-top: 0px; } menulist > menupopup > menuitem > label, @@ -250,7 +245,7 @@ menulist > menupopup > menuitem[disabled="true"]:not([_moz-menuactive="true"]):- text-shadow: none; } -menulist > menupopup > :-moz-any(menuitem, menucaption):not(.menuitem-iconic):not([endimage]) > .menu-iconic-text { +menulist > menupopup > :-moz-any(menuitem, menucaption):not(.menuitem-iconic) > .menu-iconic-text { margin: 0 !important; }