From 8c977125302a04c9be3ead5df5d93de2105dcdd5 Mon Sep 17 00:00:00 2001 From: Panos Astithas Date: Tue, 2 Aug 2011 10:43:10 -0300 Subject: [PATCH 01/15] Bug 653531 - Shared knowledge of selected node in highlighter and web console; r=rcampbell --- browser/devtools/webconsole/HUDService.jsm | 19 +++ .../webconsole/test/browser/Makefile.in | 1 + ...e_bug_653531_highlighter_console_helper.js | 148 ++++++++++++++++++ 3 files changed, 168 insertions(+) create mode 100644 browser/devtools/webconsole/test/browser/browser_webconsole_bug_653531_highlighter_console_helper.js diff --git a/browser/devtools/webconsole/HUDService.jsm b/browser/devtools/webconsole/HUDService.jsm index c2c02953d05..cafa2d4da51 100644 --- a/browser/devtools/webconsole/HUDService.jsm +++ b/browser/devtools/webconsole/HUDService.jsm @@ -4222,6 +4222,25 @@ function JSTermHelper(aJSTerm) return nodes; }; + /** + * Returns the currently selected object in the highlighter. + * + * @returns nsIDOMNode or null + */ + Object.defineProperty(aJSTerm.sandbox, "$0", { + get: function() { + let mw = HUDService.currentContext(); + try { + return mw.InspectorUI.selection; + } + catch (ex) { + aJSTerm.console.error(ex.message); + } + }, + enumerable: true, + configurable: false + }); + /** * Clears the output of the JSTerm. */ diff --git a/browser/devtools/webconsole/test/browser/Makefile.in b/browser/devtools/webconsole/test/browser/Makefile.in index ba1a57f199e..33d41487157 100644 --- a/browser/devtools/webconsole/test/browser/Makefile.in +++ b/browser/devtools/webconsole/test/browser/Makefile.in @@ -141,6 +141,7 @@ _BROWSER_TEST_FILES = \ browser_webconsole_bug_663443_panel_title.js \ browser_webconsole_bug_660806_history_nav.js \ browser_webconsole_bug_651501_document_body_autocomplete.js \ + browser_webconsole_bug_653531_highlighter_console_helper.js \ head.js \ $(NULL) diff --git a/browser/devtools/webconsole/test/browser/browser_webconsole_bug_653531_highlighter_console_helper.js b/browser/devtools/webconsole/test/browser/browser_webconsole_bug_653531_highlighter_console_helper.js new file mode 100644 index 00000000000..a1a775e70a8 --- /dev/null +++ b/browser/devtools/webconsole/test/browser/browser_webconsole_bug_653531_highlighter_console_helper.js @@ -0,0 +1,148 @@ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Inspector Highlighter Tests. + * + * The Initial Developer of the Original Code is + * The Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Rob Campbell + * Mihai Sucan + * Panos Astithas + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +// Tests that the $0 console helper works as intended. + +let doc; +let h1; + +function createDocument() +{ + let div = doc.createElement("div"); + let h1 = doc.createElement("h1"); + let p1 = doc.createElement("p"); + let p2 = doc.createElement("p"); + let div2 = doc.createElement("div"); + let p3 = doc.createElement("p"); + doc.title = "Inspector Tree Selection Test"; + h1.textContent = "Inspector Tree Selection Test"; + p1.textContent = "This is some example text"; + p2.textContent = "Lorem ipsum dolor sit amet, consectetur adipisicing " + + "elit, sed do eiusmod tempor incididunt ut labore et dolore magna " + + "aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco " + + "laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure " + + "dolor in reprehenderit in voluptate velit esse cillum dolore eu " + + "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non " + + "proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; + p3.textContent = "Lorem ipsum dolor sit amet, consectetur adipisicing " + + "elit, sed do eiusmod tempor incididunt ut labore et dolore magna " + + "aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco " + + "laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure " + + "dolor in reprehenderit in voluptate velit esse cillum dolore eu " + + "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non " + + "proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; + div.appendChild(h1); + div.appendChild(p1); + div.appendChild(p2); + div2.appendChild(p3); + doc.body.appendChild(div); + doc.body.appendChild(div2); + setupHighlighterTests(); +} + +function setupHighlighterTests() +{ + h1 = doc.querySelectorAll("h1")[0]; + ok(h1, "we have the header node"); + Services.obs.addObserver(runSelectionTests, + INSPECTOR_NOTIFICATIONS.OPENED, false); + InspectorUI.toggleInspectorUI(); +} + +function runSelectionTests() +{ + Services.obs.removeObserver(runSelectionTests, + INSPECTOR_NOTIFICATIONS.OPENED, false); + + executeSoon(function() { + Services.obs.addObserver(performTestComparisons, + INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false); + EventUtils.synthesizeMouse(h1, 2, 2, {type: "mousemove"}, content); + }); +} + +function performTestComparisons(evt) +{ + Services.obs.removeObserver(performTestComparisons, + INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false); + + InspectorUI.stopInspecting(); + ok(InspectorUI.highlighter.isHighlighting, "highlighter is highlighting"); + is(InspectorUI.selection, h1, "selection matches node"); + + HUDService.activateHUDForContext(gBrowser.selectedTab); + let hudId = HUDService.getHudIdByWindow(content); + let hud = HUDService.hudReferences[hudId]; + let jsterm = hud.jsterm; + outputNode = hud.outputNode; + + jsterm.clearOutput(); + jsterm.execute("$0"); + findLogEntry("[object HTMLHeadingElement"); + + jsterm.clearOutput(); + let msg = "foo"; + jsterm.execute("$0.textContent = '" + msg + "'"); + findLogEntry(msg); + is(InspectorUI.selection.textContent, msg, "node successfully updated"); + + doc = h1 = null; + executeSoon(finishUp); +} + +function finishUp() { + InspectorUI.closeInspectorUI(); + gBrowser.removeCurrentTab(); + finish(); +} + +function test() +{ + waitForExplicitFinish(); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.selectedBrowser.addEventListener("load", function() { + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); + doc = content.document; + waitForFocus(createDocument, content); + }, true); + + content.location = "data:text/html,test for highlighter helper in web console"; +} + From 037bcb41adb524aac4deb42e6244f22fb7ed0a80 Mon Sep 17 00:00:00 2001 From: Rob Campbell Date: Tue, 2 Aug 2011 11:11:32 -0300 Subject: [PATCH 02/15] Bug 674879 - Move Scratchpad to browser/devtools; r=gavin.sharp,mihai.sucan --HG-- rename : browser/base/content/scratchpad.js => browser/devtools/scratchpad/scratchpad.js rename : browser/base/content/scratchpad.xul => browser/devtools/scratchpad/scratchpad.xul rename : browser/base/content/test/browser_scratchpad_bug_646070_chrome_context_pref.js => browser/devtools/scratchpad/test/browser_scratchpad_bug_646070_chrome_context_pref.js rename : browser/base/content/test/browser_scratchpad_bug_660560_tab.js => browser/devtools/scratchpad/test/browser_scratchpad_bug_660560_tab.js rename : browser/base/content/test/browser_scratchpad_contexts.js => browser/devtools/scratchpad/test/browser_scratchpad_contexts.js rename : browser/base/content/test/browser_scratchpad_execute_print.js => browser/devtools/scratchpad/test/browser_scratchpad_execute_print.js rename : browser/base/content/test/browser_scratchpad_files.js => browser/devtools/scratchpad/test/browser_scratchpad_files.js rename : browser/base/content/test/browser_scratchpad_initialization.js => browser/devtools/scratchpad/test/browser_scratchpad_initialization.js rename : browser/base/content/test/browser_scratchpad_inspect.js => browser/devtools/scratchpad/test/browser_scratchpad_inspect.js rename : browser/base/content/test/browser_scratchpad_tab_switch.js => browser/devtools/scratchpad/test/browser_scratchpad_tab_switch.js rename : browser/base/content/test/browser_scratchpad_ui.js => browser/devtools/scratchpad/test/browser_scratchpad_ui.js --- browser/base/content/test/Makefile.in | 9 --- browser/base/jar.mn | 2 - browser/devtools/Makefile.in | 1 + browser/devtools/jar.mn | 2 + browser/devtools/scratchpad/Makefile.in | 52 +++++++++++++++++ .../scratchpad}/scratchpad.js | 0 .../scratchpad}/scratchpad.xul | 0 browser/devtools/scratchpad/test/Makefile.in | 58 +++++++++++++++++++ ...ratchpad_bug_646070_chrome_context_pref.js | 0 .../test/browser_scratchpad_bug_660560_tab.js | 0 .../test/browser_scratchpad_contexts.js | 0 .../test/browser_scratchpad_execute_print.js | 0 .../test/browser_scratchpad_files.js | 0 .../test/browser_scratchpad_initialization.js | 0 .../test/browser_scratchpad_inspect.js | 0 .../test/browser_scratchpad_tab_switch.js | 0 .../scratchpad}/test/browser_scratchpad_ui.js | 0 17 files changed, 113 insertions(+), 11 deletions(-) create mode 100644 browser/devtools/scratchpad/Makefile.in rename browser/{base/content => devtools/scratchpad}/scratchpad.js (100%) rename browser/{base/content => devtools/scratchpad}/scratchpad.xul (100%) create mode 100644 browser/devtools/scratchpad/test/Makefile.in rename browser/{base/content => devtools/scratchpad}/test/browser_scratchpad_bug_646070_chrome_context_pref.js (100%) rename browser/{base/content => devtools/scratchpad}/test/browser_scratchpad_bug_660560_tab.js (100%) rename browser/{base/content => devtools/scratchpad}/test/browser_scratchpad_contexts.js (100%) rename browser/{base/content => devtools/scratchpad}/test/browser_scratchpad_execute_print.js (100%) rename browser/{base/content => devtools/scratchpad}/test/browser_scratchpad_files.js (100%) rename browser/{base/content => devtools/scratchpad}/test/browser_scratchpad_initialization.js (100%) rename browser/{base/content => devtools/scratchpad}/test/browser_scratchpad_inspect.js (100%) rename browser/{base/content => devtools/scratchpad}/test/browser_scratchpad_tab_switch.js (100%) rename browser/{base/content => devtools/scratchpad}/test/browser_scratchpad_ui.js (100%) diff --git a/browser/base/content/test/Makefile.in b/browser/base/content/test/Makefile.in index 364055c8a97..b88e7936886 100644 --- a/browser/base/content/test/Makefile.in +++ b/browser/base/content/test/Makefile.in @@ -187,15 +187,6 @@ _BROWSER_FILES = \ browser_gestureSupport.js \ browser_getshortcutoruri.js \ browser_hide_removing.js \ - browser_scratchpad_initialization.js \ - browser_scratchpad_contexts.js \ - browser_scratchpad_tab_switch.js \ - browser_scratchpad_execute_print.js \ - browser_scratchpad_inspect.js \ - browser_scratchpad_files.js \ - browser_scratchpad_ui.js \ - browser_scratchpad_bug_646070_chrome_context_pref.js \ - browser_scratchpad_bug_660560_tab.js \ browser_overflowScroll.js \ browser_locationBarExternalLoad.js \ browser_pageInfo.js \ diff --git a/browser/base/jar.mn b/browser/base/jar.mn index 1cbeb7c3775..406bdc7e017 100644 --- a/browser/base/jar.mn +++ b/browser/base/jar.mn @@ -32,8 +32,6 @@ browser.jar: * content/browser/content.js (content/content.js) * content/browser/fullscreen-video.xhtml (content/fullscreen-video.xhtml) * content/browser/inspector.html (content/inspector.html) -* content/browser/scratchpad.xul (content/scratchpad.xul) -* content/browser/scratchpad.js (content/scratchpad.js) * content/browser/pageinfo/pageInfo.xul (content/pageinfo/pageInfo.xul) * content/browser/pageinfo/pageInfo.js (content/pageinfo/pageInfo.js) * content/browser/pageinfo/pageInfo.css (content/pageinfo/pageInfo.css) diff --git a/browser/devtools/Makefile.in b/browser/devtools/Makefile.in index 7a5d3d74ba3..18f018e09d1 100644 --- a/browser/devtools/Makefile.in +++ b/browser/devtools/Makefile.in @@ -47,6 +47,7 @@ include $(topsrcdir)/config/config.mk DIRS = \ webconsole \ + scratchpad \ $(NULL) ifdef ENABLE_TESTS diff --git a/browser/devtools/jar.mn b/browser/devtools/jar.mn index d3d7867fd22..b3256b14beb 100644 --- a/browser/devtools/jar.mn +++ b/browser/devtools/jar.mn @@ -1,2 +1,4 @@ browser.jar: content/browser/NetworkPanel.xhtml (webconsole/NetworkPanel.xhtml) +* content/browser/scratchpad.xul (scratchpad/scratchpad.xul) +* content/browser/scratchpad.js (scratchpad/scratchpad.js) diff --git a/browser/devtools/scratchpad/Makefile.in b/browser/devtools/scratchpad/Makefile.in new file mode 100644 index 00000000000..3c073560ec6 --- /dev/null +++ b/browser/devtools/scratchpad/Makefile.in @@ -0,0 +1,52 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is HUDService code. +# +# The Initial Developer of the Original Code is Mozilla Corporation. +# +# Portions created by the Initial Developer are Copyright (C) 2010 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Rob Campbell +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 2 or later (the "GPL"), or +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +ifdef ENABLE_TESTS +ifneq (mobile,$(MOZ_BUILD_APP)) + DIRS += test +endif +endif + +include $(topsrcdir)/config/rules.mk diff --git a/browser/base/content/scratchpad.js b/browser/devtools/scratchpad/scratchpad.js similarity index 100% rename from browser/base/content/scratchpad.js rename to browser/devtools/scratchpad/scratchpad.js diff --git a/browser/base/content/scratchpad.xul b/browser/devtools/scratchpad/scratchpad.xul similarity index 100% rename from browser/base/content/scratchpad.xul rename to browser/devtools/scratchpad/scratchpad.xul diff --git a/browser/devtools/scratchpad/test/Makefile.in b/browser/devtools/scratchpad/test/Makefile.in new file mode 100644 index 00000000000..76a1b8b6672 --- /dev/null +++ b/browser/devtools/scratchpad/test/Makefile.in @@ -0,0 +1,58 @@ +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is HUD test code. +# +# The Initial Developer of the Original Code is Mozilla Foundation. +# Portions created by the Initial Developer are Copyright (C) 2010 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Rob Campbell (Original Author) +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ +relativesrcdir = browser/devtools/scratchpad/test + +include $(DEPTH)/config/autoconf.mk +include $(topsrcdir)/config/rules.mk + +_BROWSER_TEST_FILES = \ + browser_scratchpad_initialization.js \ + browser_scratchpad_contexts.js \ + browser_scratchpad_tab_switch.js \ + browser_scratchpad_execute_print.js \ + browser_scratchpad_inspect.js \ + browser_scratchpad_files.js \ + browser_scratchpad_ui.js \ + browser_scratchpad_bug_646070_chrome_context_pref.js \ + browser_scratchpad_bug_660560_tab.js \ + +libs:: $(_BROWSER_TEST_FILES) + $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir) diff --git a/browser/base/content/test/browser_scratchpad_bug_646070_chrome_context_pref.js b/browser/devtools/scratchpad/test/browser_scratchpad_bug_646070_chrome_context_pref.js similarity index 100% rename from browser/base/content/test/browser_scratchpad_bug_646070_chrome_context_pref.js rename to browser/devtools/scratchpad/test/browser_scratchpad_bug_646070_chrome_context_pref.js diff --git a/browser/base/content/test/browser_scratchpad_bug_660560_tab.js b/browser/devtools/scratchpad/test/browser_scratchpad_bug_660560_tab.js similarity index 100% rename from browser/base/content/test/browser_scratchpad_bug_660560_tab.js rename to browser/devtools/scratchpad/test/browser_scratchpad_bug_660560_tab.js diff --git a/browser/base/content/test/browser_scratchpad_contexts.js b/browser/devtools/scratchpad/test/browser_scratchpad_contexts.js similarity index 100% rename from browser/base/content/test/browser_scratchpad_contexts.js rename to browser/devtools/scratchpad/test/browser_scratchpad_contexts.js diff --git a/browser/base/content/test/browser_scratchpad_execute_print.js b/browser/devtools/scratchpad/test/browser_scratchpad_execute_print.js similarity index 100% rename from browser/base/content/test/browser_scratchpad_execute_print.js rename to browser/devtools/scratchpad/test/browser_scratchpad_execute_print.js diff --git a/browser/base/content/test/browser_scratchpad_files.js b/browser/devtools/scratchpad/test/browser_scratchpad_files.js similarity index 100% rename from browser/base/content/test/browser_scratchpad_files.js rename to browser/devtools/scratchpad/test/browser_scratchpad_files.js diff --git a/browser/base/content/test/browser_scratchpad_initialization.js b/browser/devtools/scratchpad/test/browser_scratchpad_initialization.js similarity index 100% rename from browser/base/content/test/browser_scratchpad_initialization.js rename to browser/devtools/scratchpad/test/browser_scratchpad_initialization.js diff --git a/browser/base/content/test/browser_scratchpad_inspect.js b/browser/devtools/scratchpad/test/browser_scratchpad_inspect.js similarity index 100% rename from browser/base/content/test/browser_scratchpad_inspect.js rename to browser/devtools/scratchpad/test/browser_scratchpad_inspect.js diff --git a/browser/base/content/test/browser_scratchpad_tab_switch.js b/browser/devtools/scratchpad/test/browser_scratchpad_tab_switch.js similarity index 100% rename from browser/base/content/test/browser_scratchpad_tab_switch.js rename to browser/devtools/scratchpad/test/browser_scratchpad_tab_switch.js diff --git a/browser/base/content/test/browser_scratchpad_ui.js b/browser/devtools/scratchpad/test/browser_scratchpad_ui.js similarity index 100% rename from browser/base/content/test/browser_scratchpad_ui.js rename to browser/devtools/scratchpad/test/browser_scratchpad_ui.js From 6d9f1fc9a2024174e0b3c9878b7e85e4617e52e9 Mon Sep 17 00:00:00 2001 From: Panos Astithas Date: Thu, 9 Jun 2011 16:27:30 +0300 Subject: [PATCH 03/15] Bug 659907 - Expand console object with a dir method that displays an interactive listing of all the properties of an object.; f=rcampbell r=mihai.sucan,bzbarsky sr=bzbarsky --- browser/devtools/webconsole/HUDService.jsm | 110 ++++++++++++++++-- .../webconsole/test/browser/Makefile.in | 1 + ...owser_webconsole_bug_659907_console_dir.js | 45 +++++++ .../test/browser/test-console-extras.html | 1 - dom/base/ConsoleAPI.js | 6 + dom/tests/browser/browser_ConsoleAPITests.js | 4 + .../mochitest/general/test_consoleAPI.html | 1 + 7 files changed, 155 insertions(+), 13 deletions(-) create mode 100644 browser/devtools/webconsole/test/browser/browser_webconsole_bug_659907_console_dir.js diff --git a/browser/devtools/webconsole/HUDService.jsm b/browser/devtools/webconsole/HUDService.jsm index cafa2d4da51..64889749d1d 100644 --- a/browser/devtools/webconsole/HUDService.jsm +++ b/browser/devtools/webconsole/HUDService.jsm @@ -158,6 +158,7 @@ const LEVELS = { info: SEVERITY_INFO, log: SEVERITY_LOG, trace: SEVERITY_LOG, + dir: SEVERITY_LOG }; // The lowest HTTP response code (inclusive) that is considered an error. @@ -1235,6 +1236,10 @@ function pruneConsoleOutputIfNecessary(aHUDId, aCategory) } delete hudRef.cssNodes[desc + location]; } + else if (messageNodes[i].classList.contains("webconsole-msg-inspector")) { + hudRef.pruneConsoleDirNode(messageNodes[i]); + continue; + } messageNodes[i].parentNode.removeChild(messageNodes[i]); } @@ -1969,6 +1974,13 @@ HUD_SERVICE.prototype = clipboardText = clipboardText.trimRight(); break; + case "dir": + body = unwrap(args[0]); + clipboardText = body.toString(); + sourceURL = aMessage.filename; + sourceLine = aMessage.lineNumber; + break; + default: Cu.reportError("Unknown Console API log level: " + level); return; @@ -1980,7 +1992,8 @@ HUD_SERVICE.prototype = body, sourceURL, sourceLine, - clipboardText); + clipboardText, + level); // Make the node bring up the property panel, to allow the user to inspect // the stack trace. @@ -2014,6 +2027,14 @@ HUD_SERVICE.prototype = } ConsoleUtils.outputMessageNode(node, aHUDId); + + if (level == "dir") { + // Initialize the inspector message node, by setting the PropertyTreeView + // object on the tree view. This has to be done *after* the node is + // shown, because the tree binding must be attached first. + let tree = node.querySelector("tree"); + tree.view = node.propertyTreeView; + } }, /** @@ -3786,6 +3807,24 @@ HeadsUpDisplay.prototype = { aToolbar.appendChild(clearButton); }, + /** + * Destroy the property inspector message node. This performs the necessary + * cleanup for the tree widget and removes it from the DOM. + * + * @param nsIDOMNode aMessageNode + * The message node that contains the property inspector from a + * console.dir call. + */ + pruneConsoleDirNode: function HUD_pruneConsoleDirNode(aMessageNode) + { + aMessageNode.parentNode.removeChild(aMessageNode); + let tree = aMessageNode.querySelector("tree"); + tree.parentNode.removeChild(tree); + aMessageNode.propertyTreeView = null; + tree.view = null; + tree = null; + }, + /** * Create the Web Console UI. * @@ -4794,8 +4833,15 @@ JSTerm.prototype = { let hud = HUDService.getHudReferenceById(this.hudId); hud.cssNodes = {}; - while (hud.outputNode.firstChild) { - hud.outputNode.removeChild(hud.outputNode.firstChild); + let node = hud.outputNode; + while (node.firstChild) { + if (node.firstChild.classList && + node.firstChild.classList.contains("webconsole-msg-inspector")) { + hud.pruneConsoleDirNode(node.firstChild); + } + else { + hud.outputNode.removeChild(node.firstChild); + } } hud.HUDBox.lastTimestamp = 0; @@ -5400,6 +5446,8 @@ ConsoleUtils = { * The text that should be copied to the clipboard when this node is * copied. If omitted, defaults to the body text. If `aBody` is not * a string, then the clipboard text must be supplied. + * @param number aLevel [optional] + * The level of the console API message. * @return nsIDOMNode * The message node: a XUL richlistitem ready to be inserted into * the Web Console output node. @@ -5407,7 +5455,7 @@ ConsoleUtils = { createMessageNode: function ConsoleUtils_createMessageNode(aDocument, aCategory, aSeverity, aBody, aSourceURL, aSourceLine, - aClipboardText) { + aClipboardText, aLevel) { if (aBody instanceof Ci.nsIDOMNode && aClipboardText == null) { throw new Error("HUDService.createMessageNode(): DOM node supplied " + "without any clipboard text"); @@ -5435,12 +5483,15 @@ ConsoleUtils = { bodyNode.setAttribute("flex", "1"); bodyNode.classList.add("webconsole-msg-body"); + // Store the body text, since it is needed later for the property tree + // case. + let body = aBody; // If a string was supplied for the body, turn it into a DOM node and an // associated clipboard string now. aClipboardText = aClipboardText || (aBody + (aSourceURL ? " @ " + aSourceURL : "") + (aSourceLine ? ":" + aSourceLine : "")); - aBody = aBody instanceof Ci.nsIDOMNode ? + aBody = aBody instanceof Ci.nsIDOMNode && !(aLevel == "dir") ? aBody : aDocument.createTextNode(aBody); bodyNode.appendChild(aBody); @@ -5475,12 +5526,47 @@ ConsoleUtils = { node.timestamp = timestamp; ConsoleUtils.setMessageType(node, aCategory, aSeverity); - node.appendChild(timestampNode); // childNode[0] - node.appendChild(iconContainer); // childNode[1] - node.appendChild(bodyNode); // childNode[2] - node.appendChild(repeatContainer); // childNode[3] + node.appendChild(timestampNode); + node.appendChild(iconContainer); + // Display the object tree after the message node. + if (aLevel == "dir") { + // Make the body container, which is a vertical box, for grouping the text + // and tree widgets. + let bodyContainer = aDocument.createElement("vbox"); + bodyContainer.setAttribute("flex", "1"); + bodyContainer.appendChild(bodyNode); + // Create the tree. + let tree = createElement(aDocument, "tree", { + flex: 1, + hidecolumnpicker: "true" + }); + + let treecols = aDocument.createElement("treecols"); + let treecol = createElement(aDocument, "treecol", { + primary: "true", + flex: 1, + hideheader: "true", + ignoreincolumnpicker: "true" + }); + treecols.appendChild(treecol); + tree.appendChild(treecols); + + tree.appendChild(aDocument.createElement("treechildren")); + + bodyContainer.appendChild(tree); + node.appendChild(bodyContainer); + node.classList.add("webconsole-msg-inspector"); + // Create the treeView object. + let treeView = node.propertyTreeView = new PropertyTreeView(); + treeView.data = body; + tree.setAttribute("rows", treeView.rowCount); + } + else { + node.appendChild(bodyNode); + } + node.appendChild(repeatContainer); if (locationNode) { - node.appendChild(locationNode); // childNode[4] + node.appendChild(locationNode); } node.setAttribute("id", "console-msg-" + HUDService.sequenceId()); @@ -5683,7 +5769,7 @@ ConsoleUtils = { let lastMessage = aOutput.lastChild; // childNodes[2] is the description element - if (lastMessage && + if (lastMessage && !aNode.classList.contains("webconsole-msg-inspector") && aNode.childNodes[2].textContent == lastMessage.childNodes[2].textContent) { this.mergeFilteredMessageNode(lastMessage, aNode); @@ -5717,7 +5803,7 @@ ConsoleUtils = { (aNode.classList.contains("webconsole-msg-console") || aNode.classList.contains("webconsole-msg-exception") || aNode.classList.contains("webconsole-msg-error"))) { - isRepeated = this.filterRepeatedConsole(aNode, outputNode, aHUDId); + isRepeated = this.filterRepeatedConsole(aNode, outputNode); } if (!isRepeated) { diff --git a/browser/devtools/webconsole/test/browser/Makefile.in b/browser/devtools/webconsole/test/browser/Makefile.in index 33d41487157..ddb5874b97e 100644 --- a/browser/devtools/webconsole/test/browser/Makefile.in +++ b/browser/devtools/webconsole/test/browser/Makefile.in @@ -142,6 +142,7 @@ _BROWSER_TEST_FILES = \ browser_webconsole_bug_660806_history_nav.js \ browser_webconsole_bug_651501_document_body_autocomplete.js \ browser_webconsole_bug_653531_highlighter_console_helper.js \ + browser_webconsole_bug_659907_console_dir.js \ head.js \ $(NULL) diff --git a/browser/devtools/webconsole/test/browser/browser_webconsole_bug_659907_console_dir.js b/browser/devtools/webconsole/test/browser/browser_webconsole_bug_659907_console_dir.js new file mode 100644 index 00000000000..0aad23ed729 --- /dev/null +++ b/browser/devtools/webconsole/test/browser/browser_webconsole_bug_659907_console_dir.js @@ -0,0 +1,45 @@ +/* vim:set ts=2 sw=2 sts=2 et: */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// Tests that console.dir works as intended. + +function test() { + addTab("data:text/html,Web Console test for bug 659907: Expand console " + + "object with a dir method"); + browser.addEventListener("load", onLoad, true); +} + +function onLoad(aEvent) { + browser.removeEventListener(aEvent.type, arguments.callee, true); + + openConsole(); + let hudId = HUDService.getHudIdByWindow(content); + let hud = HUDService.hudReferences[hudId]; + outputNode = hud.outputNode; + content.console.dir(content.document); + findLogEntry("[object HTMLDocument"); + let msg = outputNode.querySelectorAll(".webconsole-msg-inspector"); + is(msg.length, 1, "one message node displayed"); + let rows = msg[0].propertyTreeView._rows; + let foundQSA = false; + let foundLocation = false; + let foundWrite = false; + for (let i = 0; i < rows.length; i++) { + if (rows[i].display == "querySelectorAll: function querySelectorAll()") { + foundQSA = true; + } + else if (rows[i].display == "location: Object") { + foundLocation = true; + } + else if (rows[i].display == "write: function write()") { + foundWrite = true; + } + } + ok(foundQSA, "found document.querySelectorAll"); + ok(foundLocation, "found document.location"); + ok(foundWrite, "found document.write"); + finishTest(); +} diff --git a/browser/devtools/webconsole/test/browser/test-console-extras.html b/browser/devtools/webconsole/test/browser/test-console-extras.html index cb5f958a280..706a1a2daaf 100644 --- a/browser/devtools/webconsole/test/browser/test-console-extras.html +++ b/browser/devtools/webconsole/test/browser/test-console-extras.html @@ -9,7 +9,6 @@ console.exception() console.assert() console.clear() - console.dir() console.dirxml() console.group() console.groupCollapsed() diff --git a/dom/base/ConsoleAPI.js b/dom/base/ConsoleAPI.js index 585fc3dec76..1fea55e0fb8 100644 --- a/dom/base/ConsoleAPI.js +++ b/dom/base/ConsoleAPI.js @@ -83,6 +83,10 @@ ConsoleAPI.prototype = { trace: function CA_trace() { self.notifyObservers(id, "trace", self.getStackTrace()); }, + // Displays an interactive listing of all the properties of an object. + dir: function CA_dir() { + self.notifyObservers(id, "dir", arguments); + }, __exposedProps__: { log: "r", info: "r", @@ -90,6 +94,7 @@ ConsoleAPI.prototype = { error: "r", debug: "r", trace: "r", + dir: "r" } }; @@ -107,6 +112,7 @@ ConsoleAPI.prototype = { error: genPropDesc('error'), debug: genPropDesc('debug'), trace: genPropDesc('trace'), + dir: genPropDesc('dir'), __noSuchMethod__: { enumerable: true, configurable: true, writable: true, value: function() {} }, __mozillaConsole__: { value: true } diff --git a/dom/tests/browser/browser_ConsoleAPITests.js b/dom/tests/browser/browser_ConsoleAPITests.js index ae16708cfd2..1d97a05e32d 100644 --- a/dom/tests/browser/browser_ConsoleAPITests.js +++ b/dom/tests/browser/browser_ConsoleAPITests.js @@ -164,6 +164,9 @@ function observeConsoleTest() { expect("warn", "arg", "extra arg", 1); win.console.warn("arg", "extra arg", 1); + expect("dir", win.toString()); + win.console.dir(win); + expect("error", "arg"); win.console.error("arg"); } @@ -178,6 +181,7 @@ function consoleAPISanityTest() { ok(win.console.warn, "console.warn is here"); ok(win.console.error, "console.error is here"); ok(win.console.trace, "console.trace is here"); + ok(win.console.dir, "console.dir is here"); } var ConsoleObserver = { diff --git a/dom/tests/mochitest/general/test_consoleAPI.html b/dom/tests/mochitest/general/test_consoleAPI.html index f12077e851e..4e5e76a6b2e 100644 --- a/dom/tests/mochitest/general/test_consoleAPI.html +++ b/dom/tests/mochitest/general/test_consoleAPI.html @@ -27,6 +27,7 @@ function doTest() { "error": "function", "debug": "function", "trace": "function", + "dir": "function", "__noSuchMethod__": "function" }; From dfcf7390ed38d3608a2939b872e6e878fad4e6f4 Mon Sep 17 00:00:00 2001 From: Paul Rouget Date: Tue, 2 Aug 2011 18:08:38 -0300 Subject: [PATCH 04/15] Bug 671689 - [highlighter] Nodes should be selectable from the HTML tree; r=rcampbell,gavin.sharp --- browser/base/content/inspector.js | 17 ++++-- .../browser_inspector_treePanel_click.js | 61 +++++++++++++++++++ 2 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 browser/base/content/test/inspector/browser_inspector_treePanel_click.js diff --git a/browser/base/content/inspector.js b/browser/base/content/inspector.js index 9a8d7d9b9ca..d076151f137 100644 --- a/browser/base/content/inspector.js +++ b/browser/base/content/inspector.js @@ -897,8 +897,10 @@ var InspectorUI = { /** * Stop inspecting webpage, detach page listeners, disable highlighter * event listeners. + * @param aPreventScroll + * Prevent scroll in the HTML tree? */ - stopInspecting: function IUI_stopInspecting() + stopInspecting: function IUI_stopInspecting(aPreventScroll) { if (!this.inspecting) { return; @@ -908,7 +910,7 @@ var InspectorUI = { this.detachPageListeners(); this.inspecting = false; if (this.highlighter.node) { - this.select(this.highlighter.node, true, true); + this.select(this.highlighter.node, true, true, !aPreventScroll); } else { this.select(null, true, true); } @@ -1048,9 +1050,16 @@ var InspectorUI = { } if (node) { - if (hitTwisty) + if (hitTwisty) { this.ioBox.toggleObject(node); - this.select(node, false, false); + } else { + if (this.inspecting) { + this.stopInspecting(true); + } else { + this.select(node, true, false); + this.highlighter.highlightNode(node); + } + } } }, diff --git a/browser/base/content/test/inspector/browser_inspector_treePanel_click.js b/browser/base/content/test/inspector/browser_inspector_treePanel_click.js new file mode 100644 index 00000000000..fb66981f915 --- /dev/null +++ b/browser/base/content/test/inspector/browser_inspector_treePanel_click.js @@ -0,0 +1,61 @@ +/* Any copyright is dedicated to the Public Domain. +http://creativecommons.org/publicdomain/zero/1.0/ */ + + +function test() { + + waitForExplicitFinish(); + + let doc; + let node1; + let node2; + + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.selectedBrowser.addEventListener("load", function onload() { + gBrowser.selectedBrowser.removeEventListener("load", onload, true); + doc = content.document; + waitForFocus(setupTest, content); + }, true); + + content.location = "data:text/html,

"; + + function setupTest() { + node1 = doc.querySelector("div"); + node2 = doc.querySelector("p"); + Services.obs.addObserver(runTests, INSPECTOR_NOTIFICATIONS.OPENED, false); + InspectorUI.toggleInspectorUI(); + } + + function runTests() { + Services.obs.removeObserver(runTests, INSPECTOR_NOTIFICATIONS.OPENED); + testNode1(); + } + + function testNode1() { + let box = InspectorUI.ioBox.createObjectBox(node1); + box.click(); + executeSoon(function() { + is(InspectorUI.selection, node1, "selection matches node"); + is(InspectorUI.highlighter.node, node1, "selection matches node"); + testNode2(); + }); + } + + function testNode2() { + let box = InspectorUI.ioBox.createObjectBox(node2); + box.click(); + executeSoon(function() { + is(InspectorUI.selection, node2, "selection matches node"); + is(InspectorUI.highlighter.node, node2, "selection matches node"); + Services.obs.addObserver(finishUp, INSPECTOR_NOTIFICATIONS.CLOSED, false); + InspectorUI.closeInspectorUI(); + }); + } + + function finishUp() { + Services.obs.removeObserver(finishUp, INSPECTOR_NOTIFICATIONS.CLOSED); + doc = node1 = node2 = null; + gBrowser.removeCurrentTab(); + finish(); + } +} From 9163fd9bbdb93de7f53b55050c52b0e413375649 Mon Sep 17 00:00:00 2001 From: Rob Campbell Date: Tue, 2 Aug 2011 18:28:49 -0300 Subject: [PATCH 05/15] Bug 666650 - [highlighter] create a global toolbar for the highlighter; r=mihai.sucan,gavin.sharp --- browser/base/content/browser.xul | 20 +++++++++++-------- browser/base/content/inspector.js | 9 +++++++-- .../browser_inspector_initialization.js | 2 ++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index de9d01bb767..a278874bd4d 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -234,14 +234,6 @@ close="true" onpopuphiding="InspectorUI.closeInspectorUI();" label="&inspectPanelTitle.label;"> - - - @@ -971,6 +963,18 @@ + Date: Tue, 2 Aug 2011 20:47:24 -0300 Subject: [PATCH 06/15] Bug 666650 - [highlighter] create a global toolbar for the highlighter; r=mihai.sucan,gavin.sharp; a=testfix --- .../test/inspector/browser_inspector_initialization.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/browser/base/content/test/inspector/browser_inspector_initialization.js b/browser/base/content/test/inspector/browser_inspector_initialization.js index cdf695a4a42..fc3add8db97 100644 --- a/browser/base/content/test/inspector/browser_inspector_initialization.js +++ b/browser/base/content/test/inspector/browser_inspector_initialization.js @@ -52,7 +52,7 @@ function runInspectorTests() Services.obs.addObserver(finishInspectorTests, INSPECTOR_NOTIFICATIONS.CLOSED, false); - is(InspectorUI.toolbar.getAttribute("collapsed"), "false", "toolbar is visible"); + ok(!InspectorUI.toolbar.hidden, "toolbar is visible"); let iframe = document.getElementById("inspector-tree-iframe"); is(InspectorUI.treeIFrame, iframe, "Inspector IFrame matches"); ok(InspectorUI.inspecting, "Inspector is inspecting"); @@ -72,7 +72,7 @@ function finishInspectorTests() ok(!InspectorUI.highlighter, "Highlighter is gone"); ok(!InspectorUI.isTreePanelOpen, "Inspector Tree Panel is closed"); ok(!InspectorUI.inspecting, "Inspector is not inspecting"); - is(InspectorUI.toolbar.getAttribute("collapsed"), "true", "toolbar is collapsed"); + ok(InspectorUI.toolbar.hidden, "toolbar is hidden"); gBrowser.removeCurrentTab(); finish(); From 8b1abc8a98d3cc9ae0b9280928edf7e7309d81af Mon Sep 17 00:00:00 2001 From: Frank Yan Date: Tue, 2 Aug 2011 17:43:08 -0700 Subject: [PATCH 07/15] Bug 554717 - Prevent audio/video controls from inheriting list-style-image. --- toolkit/content/widgets/videocontrols.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/toolkit/content/widgets/videocontrols.css b/toolkit/content/widgets/videocontrols.css index 17eb8e60004..b3ef938fb82 100644 --- a/toolkit/content/widgets/videocontrols.css +++ b/toolkit/content/widgets/videocontrols.css @@ -18,6 +18,10 @@ .mediaControlsFrame { direction: ltr; + /* Prevent unwanted style inheritance. See bug 554717. */ + list-style-image: none !important; + font: normal normal normal 100%/normal sans-serif !important; + text-decoration: none !important; } /* CSS Transitions From 433e3b3fdf46d25d6252ffb922859834ba5634b9 Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Wed, 3 Aug 2011 07:38:07 +0200 Subject: [PATCH 08/15] Bug 625668 - Resizes for single groups don't stick correctly, returning them to their userSize values; r=dietrich --- browser/base/content/tabview/items.js | 7 +- .../test/tabview/browser_tabview_bug625269.js | 120 +++++++++--------- 2 files changed, 66 insertions(+), 61 deletions(-) diff --git a/browser/base/content/tabview/items.js b/browser/base/content/tabview/items.js index 966b0c5fad4..156ab3e8d73 100644 --- a/browser/base/content/tabview/items.js +++ b/browser/base/content/tabview/items.js @@ -310,9 +310,14 @@ Item.prototype = { // Parameters: // immediately - boolean for doing the pushAway without animation pushAway: function Item_pushAway(immediately) { + var items = Items.getTopLevelItems(); + + // we need at least two top-level items to push something away + if (items.length < 2) + return; + var buffer = Math.floor(Items.defaultGutter / 2); - var items = Items.getTopLevelItems(); // setup each Item's pushAwayData attribute: items.forEach(function pushAway_setupPushAwayData(item) { var data = {}; diff --git a/browser/base/content/test/tabview/browser_tabview_bug625269.js b/browser/base/content/test/tabview/browser_tabview_bug625269.js index ad576163b72..062fdb78398 100644 --- a/browser/base/content/test/tabview/browser_tabview_bug625269.js +++ b/browser/base/content/test/tabview/browser_tabview_bug625269.js @@ -3,75 +3,75 @@ function test() { waitForExplicitFinish(); - - newWindowWithTabView(onTabViewWindowLoaded); + newWindowWithTabView(onTabViewShown); } -function onTabViewWindowLoaded(win) { - win.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); - - ok(win.TabView.isVisible(), "Tab View is visible"); - - let contentWindow = win.document.getElementById("tab-view").contentWindow; - let [originalTab] = win.gBrowser.visibleTabs; +function onTabViewShown(win) { + registerCleanupFunction(function () win.close()); + let contentWindow = win.TabView.getContentWindow(); let currentGroup = contentWindow.GroupItems.getActiveGroupItem(); + function checkResized(diffX, diffY, shouldResize, text, callback) { + let {width: origWidth, height: origHeight} = currentGroup.getBounds(); + + resizeWindow(win, diffX, diffY, function () { + let {width: newWidth, height: newHeight} = currentGroup.getBounds(); + let resized = (origWidth != newWidth || origHeight != newHeight); + + is(resized, shouldResize, text + ": The group should " + + (shouldResize ? "" : "not ") + "have been resized"); + + callback(); + }); + } + + function next() { + let test = tests.shift(); + + if (test) + checkResized.apply(this, test.concat([next])); + else + finishTest(); + } + + function finishTest() { + // reset the usersize of the group, so this should clear the "cramped" feeling. + currentGroup.setSize(100, 100, true); + currentGroup.setUserSize(); + checkResized(400, 400, false, "After clearing the cramp", finish); + } + + let tests = [ + // diffX, diffY, shouldResize, text + [ -50, -50, false, "A little smaller"], + [ 50, 50, false, "A little bigger"], + [-400, -400, true, "Much smaller"], + [ 400, 400, true, "Bigger after much smaller"], + [-400, -400, true, "Much smaller"] + ]; + + // setup currentGroup.setSize(600, 600, true); currentGroup.setUserSize(); - let down1 = function down1(resized) { - checkResized(currentGroup, 50, 50, false, "A little bigger", up1, contentWindow, win); - }; - - let up1 = function up1(resized) { - checkResized(currentGroup, -400, -400, true, "Much smaller", down2, contentWindow, win); - } - - let down2 = function down2(resized) { - checkResized(currentGroup, 400, 400, undefined, - "Bigger after much smaller: TODO (bug 625668): the group should be resized!", - up2, contentWindow, win); - }; - - let up2 = function up2(resized) { - checkResized(currentGroup, -400, -400, undefined, - "Much smaller: TODO (bug 625668): the group should be resized!", - down3, contentWindow, win); - } - - let down3 = function down3(resized) { - // reset the usersize of the group, so this should clear the "cramped" feeling. - currentGroup.setSize(100,100,true); - currentGroup.setUserSize(); - checkResized(currentGroup, 400, 400, false, - "After clearing the cramp", - up3, contentWindow, win); - }; - - let up3 = function up3(resized) { - win.close(); - finish(); - } - - // start by making it a little smaller. - checkResized(currentGroup, -50, -50, false, "A little smaller", down1, contentWindow, win); + // run the tests + next(); } -function simulateResizeBy(xDiff, yDiff, win) { - win = win || window; +// ---------- +function resizeWindow(win, diffX, diffY, callback) { + let targetWidth = win.outerWidth + diffX; + let targetHeight = win.outerHeight + diffY; - win.resizeBy(xDiff, yDiff); -} - -function checkResized(item, xDiff, yDiff, expectResized, note, callback, contentWindow, win) { - let originalBounds = new contentWindow.Rect(item.getBounds()); - simulateResizeBy(xDiff, yDiff, win); - - let newBounds = item.getBounds(); - let resized = !newBounds.equals(originalBounds); - if (expectResized !== undefined) - is(resized, expectResized, note + ": The group should " + - (expectResized ? "" : "not ") + "be resized"); - callback(resized); + win.addEventListener("resize", function onResize() { + let {outerWidth: width, outerHeight: height} = win; + if (width != targetWidth || height != targetHeight) + return; + + win.removeEventListener("resize", onResize, false); + executeSoon(callback); + }, false); + + win.resizeBy(diffX, diffY); } From 00301a3c9fd50e39c6383b0d6ebf47ac116be4e8 Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Wed, 3 Aug 2011 07:38:07 +0200 Subject: [PATCH 09/15] Bug 673729 - When a stacked group's expand button is clicked the group starts to zoom; r=dietrich --- browser/base/content/tabview/groupitems.js | 5 ++- browser/base/content/test/tabview/Makefile.in | 1 + .../test/tabview/browser_tabview_bug673729.js | 42 +++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 browser/base/content/test/tabview/browser_tabview_bug673729.js diff --git a/browser/base/content/tabview/groupitems.js b/browser/base/content/tabview/groupitems.js index 468bf66c659..1a1381c8f1d 100644 --- a/browser/base/content/tabview/groupitems.js +++ b/browser/base/content/tabview/groupitems.js @@ -1656,11 +1656,12 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), { container.mousedown(function(e) { let target = e.target; // only set the last mouse down target if it is a left click, not on the - // close button, not on the new tab button, not on the title bar and its - // element + // close button, not on the expand button, not on the title bar and its + // elements if (Utils.isLeftClick(e) && self.$closeButton[0] != target && self.$titlebar[0] != target && + self.$expander[0] != target && !self.$titlebar.contains(target) && !self.$appTabTray.contains(target)) { lastMouseDownTarget = target; diff --git a/browser/base/content/test/tabview/Makefile.in b/browser/base/content/test/tabview/Makefile.in index f480613a78b..242a1620571 100644 --- a/browser/base/content/test/tabview/Makefile.in +++ b/browser/base/content/test/tabview/Makefile.in @@ -150,6 +150,7 @@ _BROWSER_FILES = \ browser_tabview_bug663421.js \ browser_tabview_bug665502.js \ browser_tabview_bug669694.js \ + browser_tabview_bug673729.js \ browser_tabview_click_group.js \ browser_tabview_dragdrop.js \ browser_tabview_exit_button.js \ diff --git a/browser/base/content/test/tabview/browser_tabview_bug673729.js b/browser/base/content/test/tabview/browser_tabview_bug673729.js new file mode 100644 index 00000000000..d9d5978eacb --- /dev/null +++ b/browser/base/content/test/tabview/browser_tabview_bug673729.js @@ -0,0 +1,42 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function test() { + waitForExplicitFinish(); + + newWindowWithTabView(function (win) { + let cw = win.TabView.getContentWindow(); + + // turn off zoom animations + cw.gPrefBranch.setBoolPref("animate_zoom", false); + + registerCleanupFunction(function () { + cw.gPrefBranch.clearUserPref("animate_zoom"); + win.close(); + }); + + let group = cw.GroupItems.groupItems[0]; + group.setSize(100, 100, true); + + while (!group.isStacked()) + win.gBrowser.addTab(); + + waitForFocus(function () { + whenGroupIsExpanded(group, function () { + ok(win.TabView.isVisible(), "tabview is visible"); + finish(); + }); + + let expander = group.$expander[0]; + EventUtils.synthesizeMouseAtCenter(expander, {}, cw); + }, cw); + }); +} + +// ---------- +function whenGroupIsExpanded(group, callback) { + group.addSubscriber("expanded", function onExpanded() { + group.removeSubscriber("expanded", onExpanded); + executeSoon(callback); + }); +} From a801bf5ebe3e902ae2950188e2c4cf6d69fcb896 Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Wed, 3 Aug 2011 07:38:07 +0200 Subject: [PATCH 10/15] Bug 673196 - When creating a new TabGroup near the edge of the screen in Panorama, a part of it is invisible; r=dietrich --- browser/base/content/tabview/groupitems.js | 5 ++- browser/base/content/test/tabview/Makefile.in | 1 + .../test/tabview/browser_tabview_bug673196.js | 36 +++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 browser/base/content/test/tabview/browser_tabview_bug673196.js diff --git a/browser/base/content/tabview/groupitems.js b/browser/base/content/tabview/groupitems.js index 1a1381c8f1d..bd7a55d1174 100644 --- a/browser/base/content/tabview/groupitems.js +++ b/browser/base/content/tabview/groupitems.js @@ -263,11 +263,10 @@ function GroupItem(listOfEls, options) { if (options.dontPush) { this.setZ(drag.zIndex); drag.zIndex++; - } else + } else { // Calling snap will also trigger pushAway this.snap(immediately); - if ($container) - this.setBounds(rectToBe, immediately); + } if (!options.immediately && listOfEls.length > 0) $container.hide().fadeIn(); diff --git a/browser/base/content/test/tabview/Makefile.in b/browser/base/content/test/tabview/Makefile.in index 242a1620571..b823ab23352 100644 --- a/browser/base/content/test/tabview/Makefile.in +++ b/browser/base/content/test/tabview/Makefile.in @@ -150,6 +150,7 @@ _BROWSER_FILES = \ browser_tabview_bug663421.js \ browser_tabview_bug665502.js \ browser_tabview_bug669694.js \ + browser_tabview_bug673196.js \ browser_tabview_bug673729.js \ browser_tabview_click_group.js \ browser_tabview_dragdrop.js \ diff --git a/browser/base/content/test/tabview/browser_tabview_bug673196.js b/browser/base/content/test/tabview/browser_tabview_bug673196.js new file mode 100644 index 00000000000..6f4ca0c9459 --- /dev/null +++ b/browser/base/content/test/tabview/browser_tabview_bug673196.js @@ -0,0 +1,36 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function test() { + function onLoad(win) { + registerCleanupFunction(function () win.close()); + win.gBrowser.addTab(); + } + + function onShow(win) { + let cw = win.TabView.getContentWindow(); + let group = cw.GroupItems.groupItems[0]; + + // shrink the group to make some room for dragging + group.setSize(200, 200, true); + + waitForFocus(function () { + let target = group.getChild(0).container; + EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); + EventUtils.synthesizeMouse(target, 0, 300, {type: "mousemove"}, cw); + EventUtils.synthesizeMouseAtCenter(target, {type: "mouseup"}, cw); + + let newGroup = cw.GroupItems.groupItems[1]; + let groupBounds = newGroup.getBounds(); + + let safeWindowBounds = cw.Items.getSafeWindowBounds(); + ok(safeWindowBounds.contains(groupBounds), + "new group is within safe window bounds"); + + finish(); + }, cw); + } + + waitForExplicitFinish(); + newWindowWithTabView(onShow, onLoad); +} From a867bf319c2cf0bf34029fd485b7097b591cbec6 Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Wed, 3 Aug 2011 20:39:51 +0200 Subject: [PATCH 11/15] Backout changeset ef79a5b41697 (bug 663395) --- browser/base/content/tabbrowser.xml | 10 +++------- browser/base/content/test/browser_relatedTabs.js | 9 --------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index 3cde2cd05a3..a23a89c7e7d 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -1372,19 +1372,15 @@ // aReferrerURI is null or undefined if the tab is opened from // an external application or bookmark, i.e. somewhere other // than the current tab. - if (aRelatedToCurrent == null ? aReferrerURI : aRelatedToCurrent) { + if ((aRelatedToCurrent == null ? aReferrerURI : aRelatedToCurrent) && + Services.prefs.getBoolPref("browser.tabs.insertRelatedAfterCurrent")) { let newTabPos = (this._lastRelatedTab || this.selectedTab)._tPos + 1; - if (this._lastRelatedTab) this._lastRelatedTab.owner = null; else t.owner = this.selectedTab; - - if (!this.selectedTab.pinned && - Services.prefs.getBoolPref("browser.tabs.insertRelatedAfterCurrent")) - this.moveTabTo(t, newTabPos); - + this.moveTabTo(t, newTabPos); this._lastRelatedTab = t; } diff --git a/browser/base/content/test/browser_relatedTabs.js b/browser/base/content/test/browser_relatedTabs.js index e08291ba031..893f1657055 100644 --- a/browser/base/content/test/browser_relatedTabs.js +++ b/browser/base/content/test/browser_relatedTabs.js @@ -78,14 +78,5 @@ function test() { testPosition(7, 8, "blank tab without referrer opens at the end"); testPosition(8, 9, "tab without referrer opens at the end"); - gBrowser.selectedTab = tabs[0]; - gBrowser.pinTab(gBrowser.selectedTab); - addTab("http://mochi.test:8888/#8", gBrowser.currentURI); - testPosition(9, 10, "tab with referrer should open at the end when the selected tab is pinned"); - gBrowser.selectedTab = tabs[9]; - gBrowser.removeTab(tabs.pop()); - is(gBrowser.selectedTab, tabs[0], - "opening a tab from a pinned tab, selecting it and closing it should go back to the pinned tab"); - tabs.forEach(gBrowser.removeTab, gBrowser); } From 3544672a4fc61e3f0cb879f09a6e1103afb8745c Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Wed, 3 Aug 2011 12:51:29 -0700 Subject: [PATCH 12/15] update revision of Add-on SDK tests to latest tip; test-only --- testing/jetpack/jetpack-location.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/jetpack/jetpack-location.txt b/testing/jetpack/jetpack-location.txt index 489ef713add..acf7e4e5801 100644 --- a/testing/jetpack/jetpack-location.txt +++ b/testing/jetpack/jetpack-location.txt @@ -1 +1 @@ -http://hg.mozilla.org/projects/addon-sdk/archive/55619c4ed726.tar.bz2 +http://hg.mozilla.org/projects/addon-sdk/archive/cfcf0515ae75.tar.bz2 From a45586ae359e2b23af4ec7df11b097583583a514 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Wed, 3 Aug 2011 19:35:56 -0400 Subject: [PATCH 13/15] Bug 673378 - Crash at nsHTMLCanvasElement::GetContext - r=roc When UpdateContext fails, we only reset mCurrentContext, and forgot to reset mCurrentContextId. --- content/html/content/src/nsHTMLCanvasElement.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/content/html/content/src/nsHTMLCanvasElement.cpp b/content/html/content/src/nsHTMLCanvasElement.cpp index bc7fed16471..92919ea305e 100644 --- a/content/html/content/src/nsHTMLCanvasElement.cpp +++ b/content/html/content/src/nsHTMLCanvasElement.cpp @@ -581,18 +581,21 @@ nsHTMLCanvasElement::UpdateContext(nsIPropertyBag *aNewContextOptions) rv = mCurrentContext->SetIsOpaque(GetIsOpaque()); if (NS_FAILED(rv)) { mCurrentContext = nsnull; + mCurrentContextId.AssignLiteral(""); return rv; } rv = mCurrentContext->SetContextOptions(aNewContextOptions); if (NS_FAILED(rv)) { mCurrentContext = nsnull; + mCurrentContextId.AssignLiteral(""); return rv; } rv = mCurrentContext->SetDimensions(sz.width, sz.height); if (NS_FAILED(rv)) { mCurrentContext = nsnull; + mCurrentContextId.AssignLiteral(""); return rv; } From 31c386763bce3d5598eaf30415a77b4097db4923 Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Fri, 22 Jul 2011 06:40:37 -0700 Subject: [PATCH 14/15] bug 673389 - cleanup what is a conceptual parent in AccGroupInfo r=surkov --- accessible/src/base/AccGroupInfo.cpp | 58 +++++++++++++------ accessible/src/base/AccGroupInfo.h | 8 ++- accessible/src/base/nsAccessible.cpp | 2 +- .../mochitest/relations/test_general.xul | 11 ++++ 4 files changed, 60 insertions(+), 19 deletions(-) diff --git a/accessible/src/base/AccGroupInfo.cpp b/accessible/src/base/AccGroupInfo.cpp index d80c358bb6b..be9b2e1d8e5 100644 --- a/accessible/src/base/AccGroupInfo.cpp +++ b/accessible/src/base/AccGroupInfo.cpp @@ -132,27 +132,17 @@ AccGroupInfo::AccGroupInfo(nsAccessible* aItem, PRUint32 aRole) : if (mParent) return; - // Compute parent. PRUint32 parentRole = parent->Role(); - - // In the case of ARIA row in treegrid, return treegrid since ARIA - // groups aren't used to organize levels in ARIA treegrids. - if (aRole == nsIAccessibleRole::ROLE_ROW && - parentRole == nsIAccessibleRole::ROLE_TREE_TABLE) { + if (IsConceptualParent(aRole, parentRole)) mParent = parent; - return; - } - // In the case of ARIA tree, a tree can be arranged by using ARIA groups - // to organize levels. In this case the parent of the tree item will be - // a group and the previous treeitem of that should be the tree item - // parent. Or, if the parent is something other than a tree we will - // return that. - - if (parentRole != nsIAccessibleRole::ROLE_GROUPING) { - mParent = parent; + // In the case of ARIA tree (not ARIA treegrid) a tree can be arranged by + // using ARIA groups to organize levels. In this case the parent of the tree + // item will be a group and the previous treeitem of that should be the tree + // item parent. + if (parentRole != nsIAccessibleRole::ROLE_GROUPING || + aRole != nsIAccessibleRole::ROLE_OUTLINEITEM) return; - } nsAccessible* parentPrevSibling = parent->PrevSibling(); if (!parentPrevSibling) @@ -174,3 +164,37 @@ AccGroupInfo::AccGroupInfo(nsAccessible* aItem, PRUint32 aRole) : if (parentPrevSiblingRole == nsIAccessibleRole::ROLE_OUTLINEITEM) mParent = parentPrevSibling; } + +bool +AccGroupInfo::IsConceptualParent(PRUint32 aRole, PRUint32 aParentRole) +{ + if (aParentRole == nsIAccessibleRole::ROLE_OUTLINE && + aRole == nsIAccessibleRole::ROLE_OUTLINEITEM) + return true; + if ((aParentRole == nsIAccessibleRole::ROLE_TABLE || + aParentRole == nsIAccessibleRole::ROLE_TREE_TABLE) && + aRole == nsIAccessibleRole::ROLE_ROW) + return true; + if (aParentRole == nsIAccessibleRole::ROLE_ROW && + (aRole == nsIAccessibleRole::ROLE_CELL || + aRole == nsIAccessibleRole::ROLE_GRID_CELL)) + return true; + if (aParentRole == nsIAccessibleRole::ROLE_LIST && + aRole == nsIAccessibleRole::ROLE_LISTITEM) + return true; + if (aParentRole == nsIAccessibleRole::ROLE_COMBOBOX_LIST && + aRole == nsIAccessibleRole::ROLE_COMBOBOX_OPTION) + return true; + if (aParentRole == nsIAccessibleRole::ROLE_LISTBOX && + aRole == nsIAccessibleRole::ROLE_OPTION) + return true; + if (aParentRole == nsIAccessibleRole::ROLE_PAGETABLIST && + aRole == nsIAccessibleRole::ROLE_PAGETAB) + return true; + if ((aParentRole == nsIAccessibleRole::ROLE_POPUP_MENU || + aParentRole == nsIAccessibleRole::ROLE_MENUPOPUP) && + aRole == nsIAccessibleRole::ROLE_MENUITEM) + return true; + + return false; +} diff --git a/accessible/src/base/AccGroupInfo.h b/accessible/src/base/AccGroupInfo.h index ccba061d890..cd3e6768258 100644 --- a/accessible/src/base/AccGroupInfo.h +++ b/accessible/src/base/AccGroupInfo.h @@ -52,7 +52,7 @@ public: PRInt32 PosInSet() const { return mPosInSet; } PRUint32 SetSize() const { return mSetSize; } - nsAccessible* GetConceptualParent() const { return mParent; } + nsAccessible* ConceptualParent() const { return mParent; } /** * Create group info. @@ -88,6 +88,12 @@ private: return aRole; } + /** + * Return true if the given parent role is conceptual parent of the given + * role. + */ + static bool IsConceptualParent(PRUint32 aRole, PRUint32 aParentRole); + PRUint32 mPosInSet; PRUint32 mSetSize; nsAccessible* mParent; diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index 5bb814d326a..954bd868afa 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -2140,7 +2140,7 @@ nsAccessible::GetRelationByType(PRUint32 aRelationType, return NS_OK_NO_RELATION_TARGET; return nsRelUtils::AddTarget(aRelationType, aRelation, - groupInfo->GetConceptualParent()); + groupInfo->ConceptualParent()); } // If accessible is in its own Window, or is the root of a document, diff --git a/accessible/tests/mochitest/relations/test_general.xul b/accessible/tests/mochitest/relations/test_general.xul index f70254ada58..602e1176031 100644 --- a/accessible/tests/mochitest/relations/test_general.xul +++ b/accessible/tests/mochitest/relations/test_general.xul @@ -69,6 +69,10 @@ testRelation("treeitem4", RELATION_NODE_CHILD_OF, "tree"); testRelation("treeitem5", RELATION_NODE_CHILD_OF, "treeitem4"); + // no relation node_child_of for accessible contained in an unexpected + // parent + testRelation("treeitem6", RELATION_NODE_CHILD_OF, null); + // 'node child of' relation for the document having window, returns // direct accessible parent (fixed in bug 419770). var iframeElmObj = {}; @@ -146,6 +150,11 @@ title="mochitests for accessible relations"> Mozilla Bug 475298
+ + Mozilla Bug 67389 +