From cfa9b03a037bbdca77af9d2eff6ac596d5534a0a Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Tue, 10 May 2016 21:01:28 -0700 Subject: [PATCH] Back out 027b0144a1a6 (bug 1239459) for failures in responsive.html/test/browser/browser_menu_item_02.js CLOSED TREE --- .../client/responsive.html/actions/index.js | 3 -- .../client/responsive.html/actions/moz.build | 1 - .../actions/touch-simulation.js | 22 -------------- devtools/client/responsive.html/app.js | 19 +----------- .../components/global-toolbar.js | 18 ++---------- .../client/responsive.html/images/moz.build | 1 - .../responsive.html/images/touch-events.svg | 9 ------ devtools/client/responsive.html/index.css | 9 ------ devtools/client/responsive.html/manager.js | 26 ----------------- devtools/client/responsive.html/reducers.js | 1 - .../client/responsive.html/reducers/moz.build | 1 - .../reducers/touch-simulation.js | 29 ------------------- .../responsive.html/test/browser/browser.ini | 1 - .../test/browser/browser_touch_simulation.js | 25 ---------------- .../test_update_touch_simulation_enabled.js | 23 --------------- .../responsive.html/test/unit/xpcshell.ini | 1 - devtools/client/responsive.html/types.js | 10 ------- devtools/shared/touch/simulator.js | 8 ++++- 18 files changed, 10 insertions(+), 197 deletions(-) delete mode 100644 devtools/client/responsive.html/actions/touch-simulation.js delete mode 100644 devtools/client/responsive.html/images/touch-events.svg delete mode 100644 devtools/client/responsive.html/reducers/touch-simulation.js delete mode 100644 devtools/client/responsive.html/test/browser/browser_touch_simulation.js delete mode 100644 devtools/client/responsive.html/test/unit/test_update_touch_simulation_enabled.js diff --git a/devtools/client/responsive.html/actions/index.js b/devtools/client/responsive.html/actions/index.js index beb8a1e61b81..1c510ba7e7b0 100644 --- a/devtools/client/responsive.html/actions/index.js +++ b/devtools/client/responsive.html/actions/index.js @@ -44,9 +44,6 @@ createEnum([ // Update the device modal open state. "UPDATE_DEVICE_MODAL_OPEN", - // Update the touch simulation enabled state. - "UPDATE_TOUCH_SIMULATION_ENABLED", - ], module.exports); /** diff --git a/devtools/client/responsive.html/actions/moz.build b/devtools/client/responsive.html/actions/moz.build index b5ed2175f9b1..db36543d7651 100644 --- a/devtools/client/responsive.html/actions/moz.build +++ b/devtools/client/responsive.html/actions/moz.build @@ -9,6 +9,5 @@ DevToolsModules( 'index.js', 'location.js', 'screenshot.js', - 'touch-simulation.js', 'viewports.js', ) diff --git a/devtools/client/responsive.html/actions/touch-simulation.js b/devtools/client/responsive.html/actions/touch-simulation.js deleted file mode 100644 index 9950d45fbb4b..000000000000 --- a/devtools/client/responsive.html/actions/touch-simulation.js +++ /dev/null @@ -1,22 +0,0 @@ -/* 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/. */ - -/* eslint-env browser */ - -"use strict"; - -const { - UPDATE_TOUCH_SIMULATION_ENABLED -} = require("./index"); - -module.exports = { - - updateTouchSimulationEnabled(enabled) { - return { - type: UPDATE_TOUCH_SIMULATION_ENABLED, - enabled, - }; - }, - -}; diff --git a/devtools/client/responsive.html/app.js b/devtools/client/responsive.html/app.js index f72ce7d273bb..ef13410d6254 100644 --- a/devtools/client/responsive.html/app.js +++ b/devtools/client/responsive.html/app.js @@ -20,7 +20,6 @@ const { rotateViewport } = require("./actions/viewports"); const { takeScreenshot } = require("./actions/screenshot"); -const { updateTouchSimulationEnabled } = require("./actions/touch-simulation"); const DeviceModal = createFactory(require("./components/device-modal")); const GlobalToolbar = createFactory(require("./components/global-toolbar")); const Viewports = createFactory(require("./components/viewports")); @@ -31,9 +30,8 @@ let App = createClass({ propTypes: { devices: PropTypes.shape(Types.devices).isRequired, location: Types.location.isRequired, - screenshot: PropTypes.shape(Types.screenshot).isRequired, - touchSimulation: PropTypes.shape(Types.touchSimulation).isRequired, viewports: PropTypes.arrayOf(PropTypes.shape(Types.viewport)).isRequired, + screenshot: PropTypes.shape(Types.screenshot).isRequired, }, displayName: "App", @@ -82,23 +80,11 @@ let App = createClass({ this.props.dispatch(updateDeviceModalOpen(isOpen)); }, - onUpdateTouchSimulationEnabled() { - let { enabled } = this.props.touchSimulation; - - window.postMessage({ - type: "update-touch-simulation", - enabled, - }, "*"); - - this.props.dispatch(updateTouchSimulationEnabled(!enabled)); - }, - render() { let { devices, location, screenshot, - touchSimulation, viewports, } = this.props; @@ -113,7 +99,6 @@ let App = createClass({ onScreenshot, onUpdateDeviceDisplayed, onUpdateDeviceModalOpen, - onUpdateTouchSimulationEnabled, } = this; return dom.div( @@ -122,10 +107,8 @@ let App = createClass({ }, GlobalToolbar({ screenshot, - touchSimulation, onExit, onScreenshot, - onUpdateTouchSimulationEnabled, }), Viewports({ devices, diff --git a/devtools/client/responsive.html/components/global-toolbar.js b/devtools/client/responsive.html/components/global-toolbar.js index 8847548cf9e4..4a0bd4ff330d 100644 --- a/devtools/client/responsive.html/components/global-toolbar.js +++ b/devtools/client/responsive.html/components/global-toolbar.js @@ -11,11 +11,9 @@ const Types = require("../types"); module.exports = createClass({ propTypes: { - screenshot: PropTypes.shape(Types.screenshot).isRequired, - touchSimulation: PropTypes.shape(Types.touchSimulation).isRequired, onExit: PropTypes.func.isRequired, onScreenshot: PropTypes.func.isRequired, - onUpdateTouchSimulationEnabled: PropTypes.func.isRequired, + screenshot: PropTypes.shape(Types.screenshot).isRequired, }, displayName: "GlobalToolbar", @@ -24,18 +22,11 @@ module.exports = createClass({ render() { let { - screenshot, - touchSimulation, onExit, onScreenshot, - onUpdateTouchSimulationEnabled + screenshot, } = this.props; - let touchButtonClass = "toolbar-button devtools-button"; - if (touchSimulation.enabled) { - touchButtonClass += " active"; - } - return dom.header( { id: "global-toolbar", @@ -46,11 +37,6 @@ module.exports = createClass({ className: "title", }, getStr("responsive.title")), - dom.button({ - id: "global-touch-simulation-button", - className: touchButtonClass, - onClick: onUpdateTouchSimulationEnabled, - }), dom.button({ id: "global-screenshot-button", className: "toolbar-button devtools-button", diff --git a/devtools/client/responsive.html/images/moz.build b/devtools/client/responsive.html/images/moz.build index 7bc76af06aff..6954beb23644 100644 --- a/devtools/client/responsive.html/images/moz.build +++ b/devtools/client/responsive.html/images/moz.build @@ -10,5 +10,4 @@ DevToolsModules( 'rotate-viewport.svg', 'screenshot.svg', 'select-arrow.svg', - 'touch-events.svg', ) diff --git a/devtools/client/responsive.html/images/touch-events.svg b/devtools/client/responsive.html/images/touch-events.svg deleted file mode 100644 index 155056d532f8..000000000000 --- a/devtools/client/responsive.html/images/touch-events.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/devtools/client/responsive.html/index.css b/devtools/client/responsive.html/index.css index dd3375d4c479..fc44a84b0fea 100644 --- a/devtools/client/responsive.html/index.css +++ b/devtools/client/responsive.html/index.css @@ -100,15 +100,6 @@ html, body { height: 12px; } -#global-touch-simulation-button::before { - background-image: url("./images/touch-events.svg"); - margin: -6px 0 0 -6px; -} - -#global-touch-simulation-button.active::before { - filter: url("chrome://devtools/skin/images/filters.svg#checked-icon-state"); -} - #global-screenshot-button::before { background-image: url("./images/screenshot.svg"); margin: -6px 0 0 -6px; diff --git a/devtools/client/responsive.html/manager.js b/devtools/client/responsive.html/manager.js index abf7a3816ebc..7807528c7bdc 100644 --- a/devtools/client/responsive.html/manager.js +++ b/devtools/client/responsive.html/manager.js @@ -9,7 +9,6 @@ const promise = require("promise"); const { Task } = require("resource://gre/modules/Task.jsm"); const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm"); const EventEmitter = require("devtools/shared/event-emitter"); -const { TouchEventSimulator } = require("devtools/shared/touch/simulator"); const { getOwnerWindow } = require("sdk/tabs/utils"); const { on, off } = require("sdk/event/core"); const { startup } = require("sdk/window/helpers"); @@ -198,11 +197,6 @@ ResponsiveUI.prototype = { */ toolWindow: null, - /** - * Touch event simulator. - */ - touchEventSimulator: null, - /** * For the moment, we open the tool by: * 1. Recording the tab's URL @@ -226,23 +220,15 @@ ResponsiveUI.prototype = { yield waitForMessage(toolWindow, "init"); toolWindow.addInitialViewport(contentURI); yield waitForMessage(toolWindow, "browser-mounted"); - - let browser = toolWindow.document.querySelector("iframe.browser"); - this.touchEventSimulator = new TouchEventSimulator(browser); }), destroy: Task.async(function* () { let tabBrowser = this.tab.linkedBrowser; let browserWindow = this.browserWindow; - this.browserWindow = null; this.tab = null; this.inited = null; this.toolWindow = null; - - yield this.touchEventSimulator.stop(); - this.touchEventSimulator = null; - let loaded = waitForDocLoadComplete(browserWindow.gBrowser); tabBrowser.goBack(); yield loaded; @@ -268,21 +254,9 @@ ResponsiveUI.prototype = { toolWindow.removeEventListener(event.type, this); ResponsiveUIManager.closeIfNeeded(window, tab); break; - case "update-touch-simulation": - let { enabled } = event.data; - this.updateTouchSimulation(enabled); - break; } }, - updateTouchSimulation: Task.async(function* (enabled) { - if (enabled) { - this.touchEventSimulator.start(); - } else { - this.touchEventSimulator.stop(); - } - }), - getViewportSize() { return this.toolWindow.getViewportSize(); }, diff --git a/devtools/client/responsive.html/reducers.js b/devtools/client/responsive.html/reducers.js index a1f074a21ea9..86c249a23c8e 100644 --- a/devtools/client/responsive.html/reducers.js +++ b/devtools/client/responsive.html/reducers.js @@ -7,5 +7,4 @@ exports.devices = require("./reducers/devices"); exports.location = require("./reducers/location"); exports.screenshot = require("./reducers/screenshot"); -exports.touchSimulation = require("./reducers/touch-simulation"); exports.viewports = require("./reducers/viewports"); diff --git a/devtools/client/responsive.html/reducers/moz.build b/devtools/client/responsive.html/reducers/moz.build index 0db17911845d..584a216187f2 100644 --- a/devtools/client/responsive.html/reducers/moz.build +++ b/devtools/client/responsive.html/reducers/moz.build @@ -8,6 +8,5 @@ DevToolsModules( 'devices.js', 'location.js', 'screenshot.js', - 'touch-simulation.js', 'viewports.js', ) diff --git a/devtools/client/responsive.html/reducers/touch-simulation.js b/devtools/client/responsive.html/reducers/touch-simulation.js deleted file mode 100644 index e96b21276eea..000000000000 --- a/devtools/client/responsive.html/reducers/touch-simulation.js +++ /dev/null @@ -1,29 +0,0 @@ -/* 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/. */ - -"use strict"; - -const { - UPDATE_TOUCH_SIMULATION_ENABLED, -} = require("../actions/index"); - -const INITIAL_TOUCH_SIMULATION = { enabled: false }; - -let reducers = { - - [UPDATE_TOUCH_SIMULATION_ENABLED](touchSimulation, { enabled }) { - return Object.assign({}, touchSimulation, { - enabled, - }); - }, - -}; - -module.exports = function (touchSimulation = INITIAL_TOUCH_SIMULATION, action) { - let reducer = reducers[action.type]; - if (!reducer) { - return touchSimulation; - } - return reducer(touchSimulation, action); -}; diff --git a/devtools/client/responsive.html/test/browser/browser.ini b/devtools/client/responsive.html/test/browser/browser.ini index a0790706801c..5e041d94208f 100644 --- a/devtools/client/responsive.html/test/browser/browser.ini +++ b/devtools/client/responsive.html/test/browser/browser.ini @@ -19,5 +19,4 @@ skip-if = (e10s && debug) # Bug 1267278: browser.xul leaks [browser_mouse_resize.js] [browser_resize_cmd.js] [browser_screenshot_button.js] -[browser_touch_simulation.js] [browser_viewport_basics.js] diff --git a/devtools/client/responsive.html/test/browser/browser_touch_simulation.js b/devtools/client/responsive.html/test/browser/browser_touch_simulation.js deleted file mode 100644 index 8c50deb0784d..000000000000 --- a/devtools/client/responsive.html/test/browser/browser_touch_simulation.js +++ /dev/null @@ -1,25 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -// Test global touch simulation button - -const TEST_URL = "data:text/html;charset=utf-8,"; - -addRDMTask(TEST_URL, function* ({ ui }) { - let { store, document } = ui.toolWindow; - let touchButton = document.querySelector("#global-touch-simulation-button"); - - // Wait until the viewport has been added - yield waitUntilState(store, state => state.viewports.length == 1); - yield waitForFrameLoad(ui, TEST_URL); - - ok(!touchButton.classList.contains("active"), - "Touch simulation is not active by default."); - - touchButton.click(); - - ok(touchButton.classList.contains("active"), - "Touch simulation is started on click."); -}); diff --git a/devtools/client/responsive.html/test/unit/test_update_touch_simulation_enabled.js b/devtools/client/responsive.html/test/unit/test_update_touch_simulation_enabled.js deleted file mode 100644 index 22a7c37b9ff8..000000000000 --- a/devtools/client/responsive.html/test/unit/test_update_touch_simulation_enabled.js +++ /dev/null @@ -1,23 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -// Test updating the touch simulation `enabled` property - -const { - updateTouchSimulationEnabled, -} = require("devtools/client/responsive.html/actions/touch-simulation"); - -add_task(function* () { - let store = Store(); - const { getState, dispatch } = store; - - ok(!getState().touchSimulation.enabled, - "Touch simulation is disabled by default."); - - dispatch(updateTouchSimulationEnabled(true)); - - ok(getState().touchSimulation.enabled, - "Touch simulation is enabled."); -}); diff --git a/devtools/client/responsive.html/test/unit/xpcshell.ini b/devtools/client/responsive.html/test/unit/xpcshell.ini index 9f19ab174f6e..009b5fa4f84e 100644 --- a/devtools/client/responsive.html/test/unit/xpcshell.ini +++ b/devtools/client/responsive.html/test/unit/xpcshell.ini @@ -12,4 +12,3 @@ firefox-appdir = browser [test_resize_viewport.js] [test_rotate_viewport.js] [test_update_device_displayed.js] -[test_update_touch_simulation_enabled.js] diff --git a/devtools/client/responsive.html/types.js b/devtools/client/responsive.html/types.js index 823ff051cff8..012556511aa7 100644 --- a/devtools/client/responsive.html/types.js +++ b/devtools/client/responsive.html/types.js @@ -85,16 +85,6 @@ exports.screenshot = { }; -/** - * Touch simulation. - */ -exports.touchSimulation = { - - // Whether or not the touch simulation is enabled - enabled: PropTypes.bool.isRequired, - -}; - /** * A single viewport displaying a document. */ diff --git a/devtools/shared/touch/simulator.js b/devtools/shared/touch/simulator.js index 2d9c2080ce7c..f5b251db3a44 100644 --- a/devtools/shared/touch/simulator.js +++ b/devtools/shared/touch/simulator.js @@ -3,6 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; +var { Ci } = require("chrome"); var promise = require("promise"); var Services = require("Services"); @@ -24,7 +25,12 @@ function TouchEventSimulator(browser) { return simulator; } - let mm = browser.frameLoader.messageManager; + let mm = browser.messageManager; + if (!mm) { + // Maybe browser is an iframe + mm = browser.QueryInterface(Ci.nsIFrameLoaderOwner) + .frameLoader.messageManager; + } mm.loadFrameScript(FRAME_SCRIPT, true); simulator = {