diff --git a/devtools/client/locales/en-US/responsiveUI.properties b/devtools/client/locales/en-US/responsiveUI.properties index 76e75de0fe3b..50f0f8a8ddc6 100644 --- a/devtools/client/locales/en-US/responsiveUI.properties +++ b/devtools/client/locales/en-US/responsiveUI.properties @@ -18,9 +18,6 @@ responsiveUI.rotate2=Rotate # LOCALIZATION NOTE (responsiveUI.screenshot): tooltip of the screenshot button. responsiveUI.screenshot=Screenshot -# LOCALIZATION NOTE (responsiveUI.userAgentPlaceholder): placeholder for the user agent input. -responsiveUI.userAgentPlaceholder=Custom User Agent - # LOCALIZATION NOTE (responsiveUI.screenshotGeneratedFilename): The auto generated filename. # The first argument (%1$S) is the date string in yyyy-mm-dd format and the second # argument (%2$S) is the time string in HH.MM.SS format. diff --git a/devtools/client/responsivedesign/responsivedesign.jsm b/devtools/client/responsivedesign/responsivedesign.jsm index af43b7324353..3c334d165d1a 100644 --- a/devtools/client/responsivedesign/responsivedesign.jsm +++ b/devtools/client/responsivedesign/responsivedesign.jsm @@ -7,23 +7,20 @@ const Ci = Components.interfaces; const Cu = Components.utils; -var {require, loader} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -var Services = require("Services"); -var {gDevTools} = require("resource://devtools/client/framework/gDevTools.jsm"); -var EventEmitter = require("devtools/shared/event-emitter"); -var {ViewHelpers} = - require("resource://devtools/client/shared/widgets/ViewHelpers.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://devtools/client/framework/gDevTools.jsm"); +Cu.import("resource://devtools/shared/event-emitter.js"); +Cu.import("resource://devtools/client/shared/widgets/ViewHelpers.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "SystemAppProxy", + "resource://gre/modules/SystemAppProxy.jsm"); + +var { require } = Cu.import("resource://devtools/shared/Loader.jsm", {}); var Telemetry = require("devtools/client/shared/telemetry"); -var {showDoorhanger} = require("devtools/client/shared/doorhanger"); -var {TouchEventSimulator} = require("devtools/shared/touch/simulator"); -var {Task} = require("resource://gre/modules/Task.jsm"); +var { showDoorhanger } = require("devtools/client/shared/doorhanger"); +var { TouchEventSimulator } = require("devtools/shared/touch/simulator"); +var { Task } = require("resource://gre/modules/Task.jsm"); var promise = require("promise"); -loader.lazyImporter(this, "SystemAppProxy", - "resource://gre/modules/SystemAppProxy.jsm"); -loader.lazyRequireGetter(this, "DebuggerClient", - "devtools/shared/client/main", true); -loader.lazyRequireGetter(this, "DebuggerServer", - "devtools/server/main", true); this.EXPORTED_SYMBOLS = ["ResponsiveUIManager"]; @@ -212,7 +209,6 @@ function ResponsiveUI(aWindow, aTab) this.bound_startResizing = this.startResizing.bind(this); this.bound_stopResizing = this.stopResizing.bind(this); this.bound_onDrag = this.onDrag.bind(this); - this.bound_changeUA = this.changeUA.bind(this); // Events this.tab.addEventListener("TabClose", this); @@ -241,8 +237,6 @@ function ResponsiveUI(aWindow, aTab) type: "deveditionpromo", anchor: this.chromeDoc.querySelector("#content") }); - - this.connectToServer(); } ResponsiveUI.prototype = { @@ -259,27 +253,6 @@ ResponsiveUI.prototype = { } }, - connectToServer: function() { - if (!DebuggerServer.initialized) { - DebuggerServer.init(); - DebuggerServer.addBrowserActors(); - } - this.client = new DebuggerClient(DebuggerServer.connectPipe()); - this.client.connect(() => { - this.client.getTab().then(({tab}) => { - this.client.attachTab(tab.actor, (response, tabClient) => { - if (!tabClient) { - Cu.reportError("Responsive mode error: failed to attach tab"); - return; - } - this.tabClient = tabClient; - this.userAgentInput.hidden = false; - ResponsiveUIManager.emit("connectedToServer", { tab: this.tab }); - }); - }); - }); - }, - /** * Destroy the nodes. Remove listeners. Reset the style. */ @@ -331,7 +304,6 @@ ResponsiveUI.prototype = { if (this.touchEventSimulator) { this.touchEventSimulator.stop(); } - this.client.close(); this._telemetry.toolClosed("responsive"); let childOff = () => { this.mm.removeMessageListener("ResponsiveMode:Stop:Done", childOff); @@ -485,14 +457,6 @@ ResponsiveUI.prototype = { this.toolbar.appendChild(this.screenshotbutton); - this.userAgentInput = this.chromeDoc.createElement("textbox"); - this.userAgentInput.className = "devtools-responsiveui-textinput"; - this.userAgentInput.setAttribute("placeholder", - this.strings.GetStringFromName("responsiveUI.userAgentPlaceholder")); - this.userAgentInput.addEventListener("blur", this.bound_changeUA, true); - this.userAgentInput.hidden = true; - this.toolbar.appendChild(this.userAgentInput); - // Resizers let resizerTooltip = this.strings.GetStringFromName("responsiveUI.resizerTooltip"); this.resizer = this.chromeDoc.createElement("box"); @@ -888,18 +852,6 @@ ResponsiveUI.prototype = { } }), - changeUA: function() { - var value = this.userAgentInput.value; - if (value !== "") { - this.userAgentInput.setAttribute("attention", "true"); - } else { - this.userAgentInput.removeAttribute("attention", "true"); - } - this.tabClient.reconfigure({customUserAgent: value}, () => { - ResponsiveUIManager.emit("userAgentChanged", { tab: this.tab }); - }); - }, - /** * Change the size of the browser. * @@ -1075,6 +1027,6 @@ ResponsiveUI.prototype = { }, } -loader.lazyGetter(ResponsiveUI.prototype, "strings", function () { +XPCOMUtils.defineLazyGetter(ResponsiveUI.prototype, "strings", function () { return Services.strings.createBundle("chrome://devtools/locale/responsiveUI.properties"); }); diff --git a/devtools/client/responsivedesign/test/browser.ini b/devtools/client/responsivedesign/test/browser.ini index 2b8f46fcdfa6..ce1f201e9a76 100644 --- a/devtools/client/responsivedesign/test/browser.ini +++ b/devtools/client/responsivedesign/test/browser.ini @@ -13,4 +13,3 @@ skip-if = e10s && os == 'win' [browser_responsiveui_touch.js] [browser_responsiveuiaddcustompreset.js] [browser_responsive_devicewidth.js] -[browser_responsiveui_customuseragent.js] diff --git a/devtools/client/responsivedesign/test/browser_responsiveui_customuseragent.js b/devtools/client/responsivedesign/test/browser_responsiveui_customuseragent.js deleted file mode 100644 index bd45f844fa7a..000000000000 --- a/devtools/client/responsivedesign/test/browser_responsiveui_customuseragent.js +++ /dev/null @@ -1,64 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -const TEST_URI = "data:text/html, Custom User Agent test"; -const DEFAULT_UA = Cc["@mozilla.org/network/protocol;1?name=http"] - .getService(Ci.nsIHttpProtocolHandler) - .userAgent; -const CHROME_UA = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36" + - " (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"; -add_task(function*() { - yield addTab(TEST_URI); - let mgr = ResponsiveUI.ResponsiveUIManager; - let selectedTab = gBrowser.selectedTab; - - let mgrOn = once(mgr, "connectedToServer"); - mgr.toggle(window, selectedTab); - yield mgrOn; - yield testUserAgent(DEFAULT_UA); - - info("Setting UA to " + CHROME_UA); - yield setUserAgent(CHROME_UA); - yield testUserAgent(CHROME_UA); - - info("Resetting UA"); - yield setUserAgent(""); - yield testUserAgent(DEFAULT_UA); - - info("Setting UA to " + CHROME_UA); - yield setUserAgent(CHROME_UA); - yield testUserAgent(CHROME_UA); - - info("Closing responsive mode"); - let mgrOff = once(mgr, "off"); - mgr.toggle(window, selectedTab); - yield mgrOff; - yield testUserAgent(DEFAULT_UA); -}); - -function* setUserAgent(ua) { - let mgr = ResponsiveUI.ResponsiveUIManager; - let instance = mgr.getResponsiveUIForTab(gBrowser.selectedTab); - let input = instance.userAgentInput; - - input.focus(); - input.value = ua; - let onUAChanged = once(mgr, "userAgentChanged"); - input.blur(); - yield onUAChanged; - - if (ua !== "") { - ok(input.hasAttribute("attention"), "UA input should be highlighted"); - } else { - ok(!input.hasAttribute("attention"), "UA input shouldn't be highlighted"); - } -} - -function* testUserAgent(value) { - let ua = yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function*() { - return content.navigator.userAgent; - }); - is(ua, value, `UA should be set to ${value}`); -} diff --git a/devtools/client/themes/responsivedesign.inc.css b/devtools/client/themes/responsivedesign.inc.css index 6a9204c0df89..be90b9d55c39 100644 --- a/devtools/client/themes/responsivedesign.inc.css +++ b/devtools/client/themes/responsivedesign.inc.css @@ -28,22 +28,6 @@ border-bottom-width: 0; } -.devtools-responsiveui-textinput { - -moz-appearance: none; - background: #333; - color: #fff; - border: 1px solid #111; - border-radius: 2px; - padding: 5px; - width: 200px; - margin: 0; -} - -.devtools-responsiveui-textinput[attention] { - border-color: #38ace6; - background: rgba(56,172,230,0.4); -} - .devtools-responsiveui-menulist, .devtools-responsiveui-toolbarbutton { -moz-appearance: none;