From adbaf91a38c34efd871fe09ca49e9723a10be863 Mon Sep 17 00:00:00 2001 From: David Creswick Date: Wed, 27 Mar 2013 10:01:00 +0200 Subject: [PATCH] Bug 851132 - Style editor shows wrong URL when middle-clicking a file name; r=mratcliffe --- .../styleeditor/StyleEditorChrome.jsm | 10 ++++ browser/devtools/styleeditor/styleeditor.xul | 4 +- browser/devtools/styleeditor/test/Makefile.in | 1 + ...ser_styleeditor_bug_851132_middle_click.js | 60 +++++++++++++++++++ 4 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 browser/devtools/styleeditor/test/browser_styleeditor_bug_851132_middle_click.js diff --git a/browser/devtools/styleeditor/StyleEditorChrome.jsm b/browser/devtools/styleeditor/StyleEditorChrome.jsm index aa43387ae516..a83f3495a029 100644 --- a/browser/devtools/styleeditor/StyleEditorChrome.jsm +++ b/browser/devtools/styleeditor/StyleEditorChrome.jsm @@ -555,6 +555,16 @@ StyleEditorChrome.prototype = { editor.enableStyleSheet(editor.styleSheet.disabled); }); + wire(aSummary, ".stylesheet-name", { + events: { + "keypress": function onStylesheetNameActivate(aEvent) { + if (aEvent.keyCode == aEvent.DOM_VK_RETURN) { + this._view.activeSummary = aSummary; + } + }.bind(this) + } + }); + wire(aSummary, ".stylesheet-saveButton", function onSaveButton(aEvent) { aEvent.stopPropagation(); aEvent.target.blur(); diff --git a/browser/devtools/styleeditor/styleeditor.xul b/browser/devtools/styleeditor/styleeditor.xul index 6a3cff7c5f63..6b6eb54f934d 100644 --- a/browser/devtools/styleeditor/styleeditor.xul +++ b/browser/devtools/styleeditor/styleeditor.xul @@ -80,13 +80,13 @@ title="&visibilityToggle.tooltip;" accesskey="&saveButton.accesskey;">
-

+

diff --git a/browser/devtools/styleeditor/test/Makefile.in b/browser/devtools/styleeditor/test/Makefile.in index 8b3f1dfec25d..441d9c89a234 100644 --- a/browser/devtools/styleeditor/test/Makefile.in +++ b/browser/devtools/styleeditor/test/Makefile.in @@ -29,6 +29,7 @@ _BROWSER_TEST_FILES = \ browser_styleeditor_sv_keynav.js \ browser_styleeditor_sv_resize.js \ browser_styleeditor_bug_826982_location_changed.js \ + browser_styleeditor_bug_851132_middle_click.js \ head.js \ helpers.js \ four.html \ diff --git a/browser/devtools/styleeditor/test/browser_styleeditor_bug_851132_middle_click.js b/browser/devtools/styleeditor/test/browser_styleeditor_bug_851132_middle_click.js new file mode 100644 index 000000000000..502b42d7662b --- /dev/null +++ b/browser/devtools/styleeditor/test/browser_styleeditor_bug_851132_middle_click.js @@ -0,0 +1,60 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +const TESTCASE_URI = TEST_BASE + "four.html"; + +function test() { + waitForExplicitFinish(); + + addTabAndLaunchStyleEditorChromeWhenLoaded(function (aChrome) { + run(aChrome); + }); + + content.location = TESTCASE_URI; +} + +let gSEChrome, timeoutID; + +function run(aChrome) { + gSEChrome = aChrome; + gBrowser.tabContainer.addEventListener("TabOpen", onTabAdded, false); + aChrome.editors[0].addActionListener({onAttach: onEditor0Attach}); + aChrome.editors[1].addActionListener({onAttach: onEditor1Attach}); +} + +function getStylesheetNameLinkFor(aEditor) { + return gSEChrome.getSummaryElementForEditor(aEditor).querySelector(".stylesheet-name"); +} + +function onEditor0Attach(aEditor) { + waitForFocus(function () { + // left mouse click should focus editor 1 + EventUtils.synthesizeMouseAtCenter( + getStylesheetNameLinkFor(gSEChrome.editors[1]), + {button: 0}, + gChromeWindow); + }, gChromeWindow); +} + +function onEditor1Attach(aEditor) { + ok(aEditor.sourceEditor.hasFocus(), + "left mouse click has given editor 1 focus"); + + // right mouse click should not open a new tab + EventUtils.synthesizeMouseAtCenter( + getStylesheetNameLinkFor(gSEChrome.editors[2]), + {button: 1}, + gChromeWindow); + + setTimeout(finish, 0); +} + +function onTabAdded() { + ok(false, "middle mouse click has opened a new tab"); + finish(); +} + +registerCleanupFunction(function () { + gBrowser.tabContainer.removeEventListener("TabOpen", onTabAdded, false); + gSEChrome = null; +});