author | Margaret Leibovic <margaret.leibovic@gmail.com> |
Thu, 16 May 2013 10:19:40 -0700 | |
changeset 143299 | d334d36b5cf64211eb1d0edb806a15c36bff3b30 |
parent 143298 | 0f895e8c3d7f123878fa31c8745eb2db5be22bea (current diff) |
parent 132030 | feccfce43b59135148e1185f78adb315c15ef982 (diff) |
child 143300 | 5d9bbd9db49f894bafce2d4f62a55b014e321eef |
push id | 25130 |
push user | lrocha@mozilla.com |
push date | Wed, 21 Aug 2013 09:41:27 +0000 |
treeherder | mozilla-central@b2486721572e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
milestone | 24.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/CLOBBER +++ b/CLOBBER @@ -12,10 +12,9 @@ # O O # | | # O <-- Clobber O <-- Clobber # # Note: The description below will be part of the error message shown to users. # # Modifying this file will now automatically clobber the buildbot machines \o/ # -Bug 866093 - Change in .gyp file for Android builds. -Bug 861039 - Nuking and rebuilding gfx/angle without clobber caused: "No rule to make target `../../../../gfx/angle/src/compiler/ArrayBoundsClamper.cpp', needed by `ArrayBoundsClamper.o'. Stop." +Bug 852687 - changing an idl without clobbering resulted test failures
--- a/accessible/src/generic/Accessible.cpp +++ b/accessible/src/generic/Accessible.cpp @@ -625,16 +625,19 @@ Accessible::VisibilityState() nsIFrame* curFrame = frame; nsPoint framePos(0, 0); do { nsView* view = curFrame->GetView(); if (view && view->GetVisibility() == nsViewVisibility_kHide) return states::INVISIBLE; + if (nsLayoutUtils::IsPopup(curFrame)) + return 0; + // Offscreen state for background tab content and invisible for not selected // deck panel. nsIFrame* parentFrame = curFrame->GetParent(); nsDeckFrame* deckFrame = do_QueryFrame(parentFrame); if (deckFrame && deckFrame->GetSelectedBox() != curFrame) { if (deckFrame->GetContent()->IsXUL() && deckFrame->GetContent()->Tag() == nsGkAtoms::tabpanels) return states::OFFSCREEN;
--- a/accessible/src/generic/HyperTextAccessible.cpp +++ b/accessible/src/generic/HyperTextAccessible.cpp @@ -1103,23 +1103,57 @@ NS_IMETHODIMP HyperTextAccessible::GetTextAfterOffset(int32_t aOffset, AccessibleTextBoundary aBoundaryType, int32_t* aStartOffset, int32_t* aEndOffset, nsAString& aText) { if (IsDefunct()) return NS_ERROR_FAILURE; - if (aBoundaryType == BOUNDARY_CHAR) { - GetCharAt(aOffset, eGetAfter, aText, aStartOffset, aEndOffset); - return NS_OK; + int32_t offset = ConvertMagicOffset(aOffset); + if (offset < 0) + return NS_ERROR_INVALID_ARG; + + switch (aBoundaryType) { + case BOUNDARY_CHAR: + GetCharAt(aOffset, eGetAfter, aText, aStartOffset, aEndOffset); + return NS_OK; + + case BOUNDARY_WORD_START: + // Move word forward twice to find start and end offsets. + *aStartOffset = FindWordBoundary(offset, eDirNext, eStartWord); + *aEndOffset = FindWordBoundary(*aStartOffset, eDirNext, eStartWord); + return GetText(*aStartOffset, *aEndOffset, aText); + + case BOUNDARY_WORD_END: + // If the offset is a word end (except 0 offset) then move forward to find + // end offset (start offset is the given offset). Otherwise move forward + // twice to find both start and end offsets. + if (offset == 0) { + *aStartOffset = FindWordBoundary(offset, eDirNext, eEndWord); + *aEndOffset = FindWordBoundary(*aStartOffset, eDirNext, eEndWord); + } else { + *aEndOffset = FindWordBoundary(offset, eDirNext, eEndWord); + *aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eEndWord); + if (*aStartOffset != offset) { + *aStartOffset = *aEndOffset; + *aEndOffset = FindWordBoundary(*aStartOffset, eDirNext, eEndWord); + } + } + return GetText(*aStartOffset, *aEndOffset, aText); + + case BOUNDARY_LINE_START: + case BOUNDARY_LINE_END: + case BOUNDARY_ATTRIBUTE_RANGE: + return GetTextHelper(eGetAfter, aBoundaryType, aOffset, + aStartOffset, aEndOffset, aText); + + default: + return NS_ERROR_INVALID_ARG; } - - return GetTextHelper(eGetAfter, aBoundaryType, aOffset, - aStartOffset, aEndOffset, aText); } // nsIPersistentProperties // nsIAccessibleText::getTextAttributes(in boolean includeDefAttrs, // in long offset, // out long rangeStartOffset, // out long rangeEndOffset); NS_IMETHODIMP
--- a/accessible/tests/mochitest/states/test_visibility.xul +++ b/accessible/tests/mochitest/states/test_visibility.xul @@ -10,40 +10,105 @@ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> <script type="application/javascript" src="../common.js" /> <script type="application/javascript" src="../role.js" /> <script type="application/javascript" src="../states.js" /> + <script type="application/javascript" + src="../events.js" /> <script type="application/javascript"> <![CDATA[ + function openMenu(aID, aSubID, aOffscreenSubID) + { + this.menuNode = getNode(aID); + + this.eventSeq = [ + new invokerChecker(EVENT_FOCUS, this.menuNode) + ]; + + this.invoke = function openMenu_invoke() + { + this.menuNode.open = true; + } + + this.finalCheck = function openMenu_finalCheck() + { + testStates(aID, 0, 0, STATE_INVISIBLE | STATE_OFFSCREEN); + testStates(aSubID, 0, 0, STATE_INVISIBLE | STATE_OFFSCREEN); + if (aOffscreenSubID) + testStates(aOffscreenSubID, STATE_OFFSCREEN, 0, STATE_INVISIBLE); + } + + this.getID = function openMenu_invoke() + { + return "open menu '" + aID + "' and test states"; + } + } + + function closeMenu(aID, aSubID, aSub2ID) + { + this.menuNode = getNode(aID); + + this.eventSeq = [ + new invokerChecker(EVENT_FOCUS, document) + ]; + + this.invoke = function openMenu_invoke() + { + this.menuNode.open = false; + } + + this.finalCheck = function openMenu_finalCheck() + { + testStates(aID, 0, 0, STATE_INVISIBLE | STATE_OFFSCREEN); + testStates(aSubID, STATE_INVISIBLE, 0, STATE_OFFSCREEN); + testStates(aSub2ID, STATE_INVISIBLE, 0, STATE_OFFSCREEN); + } + + this.getID = function openMenu_invoke() + { + return "open menu and test states"; + } + } + + var gQueue = null; function doTest() { testStates("deck_pane2", 0, 0, STATE_INVISIBLE | STATE_OFFSCREEN); testStates("tabs_pane1", 0, 0, STATE_INVISIBLE | STATE_OFFSCREEN); testStates("tabs_pane2", STATE_OFFSCREEN, 0, STATE_INVISIBLE); - SimpleTest.finish(); + gQueue = new eventQueue(); + gQueue.push(new openMenu("mi_file1", "mi_file1.1")); + gQueue.push(new openMenu("mi_file1.2", "mi_file1.2.1", "mi_file1.2.4")); + gQueue.push(new closeMenu("mi_file1", "mi_file1.1", "mi_file1.2.1")); + gQueue.invoke(); // Will call SimpleTest.finish(); } SimpleTest.waitForExplicitFinish(); addA11yLoadEvent(doTest); ]]> </script> <hbox flex="1" style="overflow: auto;"> <body xmlns="http://www.w3.org/1999/xhtml"> <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=810260" - title=" xul:deck hidden pages shouldn't be offscreen"> + title="xul:deck hidden pages shouldn't be offscreen"> Mozilla Bug 810260 </a> + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=865591" + title="Visible menu item have offscreen state"> + Mozilla Bug 865591 + </a> <p id="display"></p> <div id="content" style="display: none"> </div> <pre id="test"> </pre> </body> @@ -60,13 +125,28 @@ <tab>tab2</tab> </tabs> <tabpanels> <description value="This is the first page" id="tabs_pane1"/> <button label="This is the second page" id="tabs_pane2"/> </tabpanels> </tabbox> + <menubar> + <menu label="File" id="mi_file1"> + <menupopup> + <menuitem label="SubFile" id="mi_file1.1"/> + <menu label="SubFile2" id="mi_file1.2"> + <menupopup style="max-height: 5em;"> + <menuitem label="SubSubFile" id="mi_file1.2.1"/> + <menuitem label="SubSubFile2" id="mi_file1.2.2"/> + <menuitem label="SubSubFile3" id="mi_file1.2.3"/> + <menuitem label="SubSubFile4" id="mi_file1.2.4"/> + </menupopup> + </menu> + </menupopup> + </menu> + </menubar> </vbox> </hbox> </window>
--- a/accessible/tests/mochitest/text/test_multiline.html +++ b/accessible/tests/mochitest/text/test_multiline.html @@ -53,60 +53,30 @@ testTextAfterOffset(8, BOUNDARY_CHAR, "t", 9, 10, "div", kOk, kOk, kOk, "divbr", kOk, kOk, kOk, "editable", kOk, kOk, kOk, "editablebr", kOk, kOk, kOk, "textarea", kOk, kOk, kOk); // BOUNDARY_WORD_START - testTextAfterOffset(0, BOUNDARY_WORD_START, "two ", 9, 13, - "div", kTodo, kTodo, kTodo, - "divbr", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "editablebr", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); + testTextAfterOffset(0, BOUNDARY_WORD_START, "two ", 9, 13, IDs); testTextAfterOffset(8, BOUNDARY_WORD_START, "two ", 9, 13, - "div", kTodo, kTodo, kTodo, - "divbr", kTodo, kTodo, kOk, - "editable", kTodo, kTodo, kTodo, - "editablebr", kTodo, kTodo, kOk, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(9, BOUNDARY_WORD_START, "words\n", 13, 19, - "div", kTodo, kTodo, kTodo, + "div", kOk, kOk, kOk, "divbr", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, + "editable", kOk, kOk, kOk, "editablebr", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); + "textarea", kOk, kOk, kOk); + testTextAfterOffset(9, BOUNDARY_WORD_START, "words\n", 13, 19, IDs); // BOUNDARY_WORD_END - testTextAfterOffset(0, BOUNDARY_WORD_END, "\n\ntwo", 7, 12, - "div", kTodo, kTodo, kTodo, - "divbr", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "editablebr", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(6, BOUNDARY_WORD_END, "\n\ntwo", 7, 12, - "div", kTodo, kTodo, kTodo, - "divbr", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "editablebr", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(7, BOUNDARY_WORD_END, "\n\ntwo", 7, 12, - "div", kOk, kOk, kOk, - "divbr", kOk, kOk, kOk, - "editable", kOk, kOk, kOk, - "editablebr", kOk, kOk, kOk, - "textarea", kOk, kOk, kOk); - testTextAfterOffset(8, BOUNDARY_WORD_END, " words", 12, 18, - "div", kTodo, kTodo, kTodo, - "divbr", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "editablebr", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); + testTextAfterOffset(0, BOUNDARY_WORD_END, "\n\ntwo", 7, 12, IDs); + testTextAfterOffset(6, BOUNDARY_WORD_END, "\n\ntwo", 7, 12, IDs); + testTextAfterOffset(7, BOUNDARY_WORD_END, "\n\ntwo", 7, 12, IDs); + testTextAfterOffset(8, BOUNDARY_WORD_END, " words", 12, 18, IDs); // BOUNDARY_LINE_START testTextAfterOffset(0, BOUNDARY_LINE_START, "\n", 8, 9, "div", kTodo, kTodo, kTodo, "divbr", kTodo, kTodo, kTodo, "editable", kTodo, kTodo, kTodo, "editablebr", kTodo, kTodo, kTodo, "textarea", kTodo, kTodo, kTodo);
--- a/accessible/tests/mochitest/text/test_singleline.html +++ b/accessible/tests/mochitest/text/test_singleline.html @@ -7,19 +7,19 @@ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script type="application/javascript" src="../common.js"></script> <script type="application/javascript" src="../text.js"></script> <script type="application/javascript"> if (navigator.platform.startsWith("Mac")) { - SimpleTest.expectAssertions(0, 20); + SimpleTest.expectAssertions(0, 14); } else { - SimpleTest.expectAssertions(20); + SimpleTest.expectAssertions(14); } function doTest() { // __h__e__l__l__o__ __m__y__ __f__r__i__e__n__d__ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 //////////////////////////////////////////////////////////////////////// @@ -54,118 +54,38 @@ // get an offset for? testTextAfterOffset(15, BOUNDARY_CHAR, "", 15, 15, "input", kOk, kTodo, kTodo, "div", kOk, kTodo, kTodo, "editable", kOk, kTodo, kTodo); testCharAfterOffset("textarea", 15, "", 16, 16); // BOUNDARY_WORD_START - testTextAfterOffset(0, BOUNDARY_WORD_START, "my ", 6, 9, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(1, BOUNDARY_WORD_START, "my ", 6, 9, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(5, BOUNDARY_WORD_START, "my ", 6, 9, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(6, BOUNDARY_WORD_START, "friend", 9, 15, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(7, BOUNDARY_WORD_START, "friend", 9, 15, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(8, BOUNDARY_WORD_START, "friend", 9, 15, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(9, BOUNDARY_WORD_START, "", 15, 15, - "input", kTodo, kTodo, kOk, - "div", kTodo, kTodo, kOk, - "editable", kTodo, kTodo, kOk, - "textarea", kTodo, kTodo, kOk); - testTextAfterOffset(11, BOUNDARY_WORD_START, "", 15, 15, - "input", kTodo, kTodo, kOk, - "div", kTodo, kTodo, kOk, - "editable", kTodo, kTodo, kOk, - "textarea", kTodo, kTodo, kOk); - testTextAfterOffset(14, BOUNDARY_WORD_START, "", 15, 15, - "input", kTodo, kTodo, kOk, - "div", kTodo, kTodo, kOk, - "editable", kTodo, kTodo, kOk, - "textarea", kTodo, kTodo, kOk); - testTextAfterOffset(15, BOUNDARY_WORD_START, "", 15, 15, - "input", kOk, kOk, kOk, - "div", kOk, kOk, kOk, - "editable", kOk, kOk, kOk, - "textarea", kTodo, kOk, kTodo); + testTextAfterOffset(0, BOUNDARY_WORD_START, "my ", 6, 9, IDs); + testTextAfterOffset(1, BOUNDARY_WORD_START, "my ", 6, 9, IDs); + testTextAfterOffset(5, BOUNDARY_WORD_START, "my ", 6, 9, IDs); + testTextAfterOffset(6, BOUNDARY_WORD_START, "friend", 9, 15, IDs); + testTextAfterOffset(7, BOUNDARY_WORD_START, "friend", 9, 15, IDs); + testTextAfterOffset(8, BOUNDARY_WORD_START, "friend", 9, 15, IDs); + testTextAfterOffset(9, BOUNDARY_WORD_START, "", 15, 15, IDs); + testTextAfterOffset(11, BOUNDARY_WORD_START, "", 15, 15, IDs); + testTextAfterOffset(14, BOUNDARY_WORD_START, "", 15, 15, IDs); + testTextAfterOffset(15, BOUNDARY_WORD_START, "", 15, 15, IDs); // BOUNDARY_WORD_END - testTextAfterOffset(0, BOUNDARY_WORD_END, " my", 5, 8, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(1, BOUNDARY_WORD_END, " my", 5, 8, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(5, BOUNDARY_WORD_END, " my", 5, 8, - "input", kOk, kOk, kOk, - "div", kOk, kOk, kOk, - "editable", kOk, kOk, kOk, - "textarea", kOk, kOk, kOk); - testTextAfterOffset(6, BOUNDARY_WORD_END, " friend", 8, 15, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(7, BOUNDARY_WORD_END, " friend", 8, 15, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(8, BOUNDARY_WORD_END, " friend", 8, 15, - "input", kOk, kOk, kOk, - "div", kOk, kOk, kOk, - "editable", kOk, kOk, kOk, - "textarea", kOk, kOk, kOk); - testTextAfterOffset(9, BOUNDARY_WORD_END, "", 15, 15, - "input", kTodo, kTodo, kOk, - "div", kTodo, kTodo, kOk, - "editable", kTodo, kTodo, kOk, - "textarea", kTodo, kTodo, kOk); - testTextAfterOffset(11, BOUNDARY_WORD_END, "", 15, 15, - "input", kTodo, kTodo, kOk, - "div", kTodo, kTodo, kOk, - "editable", kTodo, kTodo, kOk, - "textarea", kTodo, kTodo, kOk); - testTextAfterOffset(14, BOUNDARY_WORD_END, "", 15, 15, - "input", kTodo, kTodo, kOk, - "div", kTodo, kTodo, kOk, - "editable", kTodo, kTodo, kOk, - "textarea", kTodo, kTodo, kOk); - testTextAfterOffset(15, BOUNDARY_WORD_END, "", 15, 15, - "input", kOk, kOk, kOk, - "div", kOk, kOk, kOk, - "editable", kOk, kOk, kOk, - "textarea", kTodo, kOk, kTodo); + testTextAfterOffset(0, BOUNDARY_WORD_END, " my", 5, 8, IDs); + testTextAfterOffset(1, BOUNDARY_WORD_END, " my", 5, 8, IDs); + testTextAfterOffset(5, BOUNDARY_WORD_END, " my", 5, 8, IDs); + testTextAfterOffset(6, BOUNDARY_WORD_END, " friend", 8, 15, IDs); + testTextAfterOffset(7, BOUNDARY_WORD_END, " friend", 8, 15, IDs); + testTextAfterOffset(8, BOUNDARY_WORD_END, " friend", 8, 15, IDs); + testTextAfterOffset(9, BOUNDARY_WORD_END, "", 15, 15, IDs); + testTextAfterOffset(11, BOUNDARY_WORD_END, "", 15, 15, IDs); + testTextAfterOffset(14, BOUNDARY_WORD_END, "", 15, 15, IDs); + testTextAfterOffset(15, BOUNDARY_WORD_END, "", 15, 15, IDs); // BOUNDARY_LINE_START testTextAfterOffset(0, BOUNDARY_LINE_START, "", 15, 15, "input", kTodo, kTodo, kOk, "div", kTodo, kTodo, kOk, "editable", kTodo, kTodo, kOk, "textarea", kTodo, kTodo, kTodo); testTextAfterOffset(1, BOUNDARY_LINE_START, "", 15, 15,
--- a/accessible/tests/mochitest/text/test_whitespaces.html +++ b/accessible/tests/mochitest/text/test_whitespaces.html @@ -8,22 +8,16 @@ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script type="application/javascript" src="../common.js"></script> <script type="application/javascript" src="../text.js"></script> <script type="application/javascript"> - if (navigator.platform.startsWith("Mac")) { - SimpleTest.expectAssertions(0, 3); - } else { - SimpleTest.expectAssertions(3); - } - function doTest() { // __B__r__a__v__e__ __S__i__r__ __ __R__o__b__i__n__ __ __ __r__a__n // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 //////////////////////////////////////////////////////////////////////// // characterCount @@ -55,138 +49,78 @@ testCharAfterOffset(IDs, 9, " ", 10, 11); testCharAfterOffset(IDs, 10, "R", 11, 12); testCharAfterOffset(IDs, 15, " ", 16, 17); testCharAfterOffset(IDs, 16, " ", 17, 18); testCharAfterOffset(IDs, 17, " ", 18, 19); testCharAfterOffset(IDs, 18, "r", 19, 20); // BOUNDARY_WORD_START - testTextAfterOffset(0, BOUNDARY_WORD_START, "Sir ", 6, 11, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(5, BOUNDARY_WORD_START, "Sir ", 6, 11, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(6, BOUNDARY_WORD_START, "Robin ", 11, 19, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(9, BOUNDARY_WORD_START, "Robin ", 11, 19, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(10, BOUNDARY_WORD_START, "Robin ", 11, 19, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); + testTextAfterOffset(0, BOUNDARY_WORD_START, "Sir ", 6, 11, IDs); + testTextAfterOffset(5, BOUNDARY_WORD_START, "Sir ", 6, 11, IDs); + testTextAfterOffset(6, BOUNDARY_WORD_START, "Robin ", 11, 19, IDs); + testTextAfterOffset(9, BOUNDARY_WORD_START, "Robin ", 11, 19, IDs); + testTextAfterOffset(10, BOUNDARY_WORD_START, "Robin ", 11, 19, IDs); testTextAfterOffset(11, BOUNDARY_WORD_START, "ran", 19, 22, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); + "input", kOk, kOk, kOk, + "div", kOk, kOk, kOk, + "editable", kOk, kOk, kOk, + "textarea", kTodo, kOk, kTodo); testTextAfterOffset(16, BOUNDARY_WORD_START, "ran", 19, 22, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); + "input", kOk, kOk, kOk, + "div", kOk, kOk, kOk, + "editable", kOk, kOk, kOk, + "textarea", kTodo, kOk, kTodo); testTextAfterOffset(18, BOUNDARY_WORD_START, "ran", 19, 22, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); + "input", kOk, kOk, kOk, + "div", kOk, kOk, kOk, + "editable", kOk, kOk, kOk, + "textarea", kTodo, kOk, kTodo); testTextAfterOffset(19, BOUNDARY_WORD_START, "", 22, 22, - "input", kTodo, kTodo, kOk, - "div", kTodo, kTodo, kOk, - "editable", kTodo, kTodo, kOk, - "textarea", kTodo, kTodo, kTodo); - - // BOUNDARY_WORD_END - testTextAfterOffset(0, BOUNDARY_WORD_END, " Sir", 5, 9, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(4, BOUNDARY_WORD_END, " Sir", 5, 9, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(5, BOUNDARY_WORD_END, " Sir", 5, 9, "input", kOk, kOk, kOk, "div", kOk, kOk, kOk, "editable", kOk, kOk, kOk, - "textarea", kOk, kOk, kOk); - testTextAfterOffset(6, BOUNDARY_WORD_END, " Robin", 9, 16, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(8, BOUNDARY_WORD_END, " Robin", 9, 16, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(9, BOUNDARY_WORD_END, " Robin", 9, 16, + "textarea", kOk, kTodo, kTodo); + + // BOUNDARY_WORD_END + testTextAfterOffset(0, BOUNDARY_WORD_END, " Sir", 5, 9, IDs); + testTextAfterOffset(4, BOUNDARY_WORD_END, " Sir", 5, 9, IDs); + testTextAfterOffset(5, BOUNDARY_WORD_END, " Sir", 5, 9, IDs); + testTextAfterOffset(6, BOUNDARY_WORD_END, " Robin", 9, 16, IDs); + testTextAfterOffset(8, BOUNDARY_WORD_END, " Robin", 9, 16, IDs); + testTextAfterOffset(9, BOUNDARY_WORD_END, " Robin", 9, 16, IDs); + testTextAfterOffset(10, BOUNDARY_WORD_END, " ran", 16, 22, IDs); + testTextAfterOffset(11, BOUNDARY_WORD_END, " ran", 16, 22, IDs); + testTextAfterOffset(15, BOUNDARY_WORD_END, " ran", 16, 22, IDs); + testTextAfterOffset(16, BOUNDARY_WORD_END, " ran", 16, 22, IDs); + testTextAfterOffset(17, BOUNDARY_WORD_END, "", 22, 22, "input", kOk, kOk, kOk, "div", kOk, kOk, kOk, "editable", kOk, kOk, kOk, - "textarea", kOk, kOk, kOk); - testTextAfterOffset(10, BOUNDARY_WORD_END, " ran", 16, 22, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(11, BOUNDARY_WORD_END, " ran", 16, 22, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(15, BOUNDARY_WORD_END, " ran", 16, 22, - "input", kTodo, kTodo, kTodo, - "div", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); - testTextAfterOffset(16, BOUNDARY_WORD_END, " ran", 16, 22, + "textarea", kTodo, kOk, kTodo); + testTextAfterOffset(18, BOUNDARY_WORD_END, "", 22, 22, "input", kOk, kOk, kOk, "div", kOk, kOk, kOk, "editable", kOk, kOk, kOk, - "textarea", kOk, kOk, kOk); - testTextAfterOffset(17, BOUNDARY_WORD_END, "", 22, 22, - "input", kTodo, kTodo, kOk, - "div", kTodo, kTodo, kOk, - "editable", kTodo, kTodo, kOk, - "textarea", kTodo, kTodo, kOk); - testTextAfterOffset(18, BOUNDARY_WORD_END, "", 22, 22, - "input", kTodo, kTodo, kOk, - "div", kTodo, kTodo, kOk, - "editable", kTodo, kTodo, kOk, - "textarea", kTodo, kTodo, kOk); + "textarea", kTodo, kOk, kTodo); testTextAfterOffset(19, BOUNDARY_WORD_END, "", 22, 22, - "input", kTodo, kTodo, kOk, - "div", kTodo, kTodo, kOk, - "editable", kTodo, kTodo, kOk, - "textarea", kTodo, kTodo, kOk); + "input", kOk, kOk, kOk, + "div", kOk, kOk, kOk, + "editable", kOk, kOk, kOk, + "textarea", kTodo, kOk, kTodo); testTextAfterOffset(21, BOUNDARY_WORD_END, "", 22, 22, - "input", kTodo, kTodo, kOk, - "div", kTodo, kTodo, kOk, - "editable", kTodo, kTodo, kOk, - "textarea", kTodo, kTodo, kOk); + "input", kOk, kOk, kOk, + "div", kOk, kOk, kOk, + "editable", kOk, kOk, kOk, + "textarea", kTodo, kOk, kTodo); testTextAfterOffset(22, BOUNDARY_WORD_END, "", 22, 22, "input", kOk, kOk, kOk, "div", kOk, kOk, kOk, "editable", kOk, kOk, kOk, - "textarea", kTodo, kOk, kTodo); + "textarea", kOk, kTodo, kTodo); //////////////////////////////////////////////////////////////////////// // getTextBeforeOffset var IDs = [ "input", "div", "editable", "textarea" ]; // BOUNDARY_CHAR testCharBeforeOffset(IDs, 0, "", 0, 0);
--- a/addon-sdk/test/Makefile.in +++ b/addon-sdk/test/Makefile.in @@ -3,12 +3,10 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. DEPTH = @DEPTH@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ relativesrcdir = @relativesrcdir@ -DISABLED_XPCSHELL_TESTS = unit - include $(DEPTH)/config/autoconf.mk include $(topsrcdir)/config/rules.mk
deleted file mode 100644 --- a/b2g/app/BootAnimation.cpp +++ /dev/null @@ -1,628 +0,0 @@ -/* Copyright 2012 Mozilla Foundation and Mozilla contributors - * - * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <algorithm> -#include <endian.h> -#include <fcntl.h> -#include <string> -#include <sys/mman.h> -#include <sys/stat.h> -#include <vector> -#include "mozilla/FileUtils.h" -#include "mozilla/NullPtr.h" -#include "mozilla/Util.h" -#include "png.h" - -#include "android/log.h" -#include "ui/FramebufferNativeWindow.h" -#include "hardware_legacy/power.h" -#include "hardware/gralloc.h" - -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args) -#define LOGW(args...) __android_log_print(ANDROID_LOG_WARN, "Gonk", ## args) -#define LOGE(args...) __android_log_print(ANDROID_LOG_ERROR, "Gonk", ## args) - -using namespace android; -using namespace mozilla; -using namespace std; - -static sp<FramebufferNativeWindow> gNativeWindow; -static pthread_t sAnimationThread; -static bool sRunAnimation; - -/* See http://www.pkware.com/documents/casestudies/APPNOTE.TXT */ -struct local_file_header { - uint32_t signature; - uint16_t min_version; - uint16_t general_flag; - uint16_t compression; - uint16_t lastmod_time; - uint16_t lastmod_date; - uint32_t crc32; - uint32_t compressed_size; - uint32_t uncompressed_size; - uint16_t filename_size; - uint16_t extra_field_size; - char data[0]; - - uint32_t GetDataSize() const - { - return letoh32(uncompressed_size); - } - - uint32_t GetSize() const - { - /* XXX account for data descriptor */ - return sizeof(local_file_header) + letoh16(filename_size) + - letoh16(extra_field_size) + GetDataSize(); - } - - const char * GetData() const - { - return data + letoh16(filename_size) + letoh16(extra_field_size); - } -} __attribute__((__packed__)); - -struct data_descriptor { - uint32_t crc32; - uint32_t compressed_size; - uint32_t uncompressed_size; -} __attribute__((__packed__)); - -struct cdir_entry { - uint32_t signature; - uint16_t creator_version; - uint16_t min_version; - uint16_t general_flag; - uint16_t compression; - uint16_t lastmod_time; - uint16_t lastmod_date; - uint32_t crc32; - uint32_t compressed_size; - uint32_t uncompressed_size; - uint16_t filename_size; - uint16_t extra_field_size; - uint16_t file_comment_size; - uint16_t disk_num; - uint16_t internal_attr; - uint32_t external_attr; - uint32_t offset; - char data[0]; - - uint32_t GetDataSize() const - { - return letoh32(compressed_size); - } - - uint32_t GetSize() const - { - return sizeof(cdir_entry) + letoh16(filename_size) + - letoh16(extra_field_size) + letoh16(file_comment_size); - } - - bool Valid() const - { - return signature == htole32(0x02014b50); - } -} __attribute__((__packed__)); - -struct cdir_end { - uint32_t signature; - uint16_t disk_num; - uint16_t cdir_disk; - uint16_t disk_entries; - uint16_t cdir_entries; - uint32_t cdir_size; - uint32_t cdir_offset; - uint16_t comment_size; - char comment[0]; - - bool Valid() const - { - return signature == htole32(0x06054b50); - } -} __attribute__((__packed__)); - -/* We don't have access to libjar and the zip reader in android - * doesn't quite fit what we want to do. */ -class ZipReader { - const char *mBuf; - const cdir_end *mEnd; - const char *mCdir_limit; - uint32_t mBuflen; - -public: - ZipReader() : mBuf(nullptr) {} - ~ZipReader() { - if (mBuf) - munmap((void *)mBuf, mBuflen); - } - - bool OpenArchive(const char *path) - { - int fd; - do { - fd = open(path, O_RDONLY); - } while (fd == -1 && errno == EINTR); - if (fd == -1) - return false; - - struct stat sb; - if (fstat(fd, &sb) == -1 || sb.st_size < sizeof(cdir_end)) { - close(fd); - return false; - } - - mBuflen = sb.st_size; - mBuf = (char *)mmap(nullptr, sb.st_size, PROT_READ, MAP_SHARED, fd, 0); - close(fd); - - if (!mBuf) { - return false; - } - - madvise(mBuf, sb.st_size, MADV_SEQUENTIAL); - - mEnd = (cdir_end *)(mBuf + mBuflen - sizeof(cdir_end)); - while (!mEnd->Valid() && - (char *)mEnd > mBuf) { - mEnd = (cdir_end *)((char *)mEnd - 1); - } - - mCdir_limit = mBuf + letoh32(mEnd->cdir_offset) + letoh32(mEnd->cdir_size); - - if (!mEnd->Valid() || mCdir_limit > (char *)mEnd) { - munmap((void *)mBuf, mBuflen); - mBuf = nullptr; - return false; - } - - return true; - } - - /* Pass null to get the first cdir entry */ - const cdir_entry * GetNextEntry(const cdir_entry *prev) - { - const cdir_entry *entry; - if (prev) - entry = (cdir_entry *)((char *)prev + prev->GetSize()); - else - entry = (cdir_entry *)(mBuf + letoh32(mEnd->cdir_offset)); - - if (((char *)entry + entry->GetSize()) > mCdir_limit || - !entry->Valid()) - return nullptr; - return entry; - } - - string GetEntryName(const cdir_entry *entry) - { - uint16_t len = letoh16(entry->filename_size); - - string name; - name.append(entry->data, len); - return name; - } - - const local_file_header * GetLocalEntry(const cdir_entry *entry) - { - const local_file_header * data = - (local_file_header *)(mBuf + letoh32(entry->offset)); - if (((char *)data + data->GetSize()) > (char *)mEnd) - return nullptr; - return data; - } -}; - -struct AnimationFrame { - char path[256]; - char *buf; - const local_file_header *file; - uint32_t width; - uint32_t height; - uint16_t bytepp; - - AnimationFrame() : buf(nullptr) {} - AnimationFrame(const AnimationFrame &frame) : buf(nullptr) { - strncpy(path, frame.path, sizeof(path)); - file = frame.file; - } - ~AnimationFrame() - { - if (buf) - free(buf); - } - - bool operator<(const AnimationFrame &other) const - { - return strcmp(path, other.path) < 0; - } - - void ReadPngFrame(int outputFormat); -}; - -struct AnimationPart { - int32_t count; - int32_t pause; - char path[256]; - vector<AnimationFrame> frames; -}; - -using namespace android; - -struct RawReadState { - const char *start; - uint32_t offset; - uint32_t length; -}; - -static void -RawReader(png_structp png_ptr, png_bytep data, png_size_t length) -{ - RawReadState *state = (RawReadState *)png_get_io_ptr(png_ptr); - if (length > (state->length - state->offset)) - png_err(png_ptr); - - memcpy(data, state->start + state->offset, length); - state->offset += length; -} - -static void -TransformTo565(png_structp png_ptr, png_row_infop row_info, png_bytep data) -{ - uint16_t *outbuf = (uint16_t *)data; - uint8_t *inbuf = (uint8_t *)data; - for (int i = 0; i < row_info->rowbytes; i += 3) { - *outbuf++ = ((inbuf[i] & 0xF8) << 8) | - ((inbuf[i + 1] & 0xFC) << 3) | - ((inbuf[i + 2] ) >> 3); - } -} - -void -AnimationFrame::ReadPngFrame(int outputFormat) -{ -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - static const png_byte unused_chunks[] = - { 98, 75, 71, 68, '\0', /* bKGD */ - 99, 72, 82, 77, '\0', /* cHRM */ - 104, 73, 83, 84, '\0', /* hIST */ - 105, 67, 67, 80, '\0', /* iCCP */ - 105, 84, 88, 116, '\0', /* iTXt */ - 111, 70, 70, 115, '\0', /* oFFs */ - 112, 67, 65, 76, '\0', /* pCAL */ - 115, 67, 65, 76, '\0', /* sCAL */ - 112, 72, 89, 115, '\0', /* pHYs */ - 115, 66, 73, 84, '\0', /* sBIT */ - 115, 80, 76, 84, '\0', /* sPLT */ - 116, 69, 88, 116, '\0', /* tEXt */ - 116, 73, 77, 69, '\0', /* tIME */ - 122, 84, 88, 116, '\0'}; /* zTXt */ - static const png_byte tRNS_chunk[] = - {116, 82, 78, 83, '\0'}; /* tRNS */ -#endif - - png_structp pngread = png_create_read_struct(PNG_LIBPNG_VER_STRING, - nullptr, nullptr, nullptr); - - if (!pngread) - return; - - png_infop pnginfo = png_create_info_struct(pngread); - - if (!pnginfo) { - png_destroy_read_struct(&pngread, &pnginfo, nullptr); - return; - } - - if (setjmp(png_jmpbuf(pngread))) { - // libpng reported an error and longjumped here. Clean up and return. - png_destroy_read_struct(&pngread, &pnginfo, nullptr); - return; - } - - RawReadState state; - state.start = file->GetData(); - state.length = file->GetDataSize(); - state.offset = 0; - - png_set_read_fn(pngread, &state, RawReader); - -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - /* Ignore unused chunks */ - png_set_keep_unknown_chunks(pngread, 1, unused_chunks, - (int)sizeof(unused_chunks)/5); - - /* Ignore the tRNS chunk if we only want opaque output */ - if (outputFormat == HAL_PIXEL_FORMAT_RGB_888 || - outputFormat == HAL_PIXEL_FORMAT_RGB_565) { - png_set_keep_unknown_chunks(pngread, 1, tRNS_chunk, 1); - } -#endif - - png_read_info(pngread, pnginfo); - - width = png_get_image_width(pngread, pnginfo); - height = png_get_image_height(pngread, pnginfo); - - switch (outputFormat) { - case HAL_PIXEL_FORMAT_BGRA_8888: - png_set_bgr(pngread); - // FALL THROUGH - case HAL_PIXEL_FORMAT_RGBA_8888: - case HAL_PIXEL_FORMAT_RGBX_8888: - bytepp = 4; - png_set_filler(pngread, 0xFF, PNG_FILLER_AFTER); - break; - case HAL_PIXEL_FORMAT_RGB_888: - bytepp = 3; - png_set_strip_alpha(pngread); - break; - default: - LOGW("Unknown pixel format %d. Assuming RGB 565.", outputFormat); - // FALL THROUGH - case HAL_PIXEL_FORMAT_RGB_565: - bytepp = 2; - png_set_strip_alpha(pngread); - png_set_read_user_transform_fn(pngread, TransformTo565); - break; - } - - // An extra row is added to give libpng enough space when - // decoding 3/4 bytepp inputs for 2 bytepp output surfaces - buf = (char *)malloc(width * (height + 1) * bytepp); - - vector<char *> rows(height + 1); - uint32_t stride = width * bytepp; - for (int i = 0; i < height; i++) { - rows[i] = buf + (stride * i); - } - rows[height] = nullptr; - png_set_strip_16(pngread); - png_set_palette_to_rgb(pngread); - png_set_gray_to_rgb(pngread); - png_read_image(pngread, (png_bytepp)&rows.front()); - png_destroy_read_struct(&pngread, &pnginfo, nullptr); -} - -static void * -AnimationThread(void *) -{ - ZipReader reader; - if (!reader.OpenArchive("/system/media/bootanimation.zip")) { - LOGW("Could not open boot animation"); - return nullptr; - } - - const cdir_entry *entry = nullptr; - const local_file_header *file = nullptr; - while ((entry = reader.GetNextEntry(entry))) { - string name = reader.GetEntryName(entry); - if (!name.compare("desc.txt")) { - file = reader.GetLocalEntry(entry); - break; - } - } - - if (!file) { - LOGW("Could not find desc.txt in boot animation"); - return nullptr; - } - - int format; - ANativeWindow *window = gNativeWindow.get(); - window->query(window, NATIVE_WINDOW_FORMAT, &format); - - hw_module_t const *module; - if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module)) { - LOGW("Could not get gralloc module"); - return nullptr; - } - gralloc_module_t const *grmodule = - reinterpret_cast<gralloc_module_t const*>(module); - - string descCopy; - descCopy.append(file->GetData(), entry->GetDataSize()); - int32_t width, height, fps; - const char *line = descCopy.c_str(); - const char *end; - bool headerRead = true; - vector<AnimationPart> parts; - - /* - * bootanimation.zip - * - * This is the boot animation file format that Android uses. - * It's a zip file with a directories containing png frames - * and a desc.txt that describes how they should be played. - * - * desc.txt contains two types of lines - * 1. [width] [height] [fps] - * There is one of these lines per bootanimation. - * If the width and height are smaller than the screen, - * the frames are centered on a black background. - * XXX: Currently we stretch instead of centering the frame. - * 2. p [count] [pause] [path] - * This describes one animation part. - * Each animation part is played in sequence. - * An animation part contains all the files/frames in the - * directory specified in [path] - * [count] indicates the number of times this part repeats. - * [pause] indicates the number of frames that this part - * should pause for after playing the full sequence but - * before repeating. - */ - - do { - end = strstr(line, "\n"); - - AnimationPart part; - if (headerRead && - sscanf(line, "%d %d %d", &width, &height, &fps) == 3) { - headerRead = false; - } else if (sscanf(line, "p %d %d %s", - &part.count, &part.pause, part.path)) { - parts.push_back(part); - } - } while (end && *(line = end + 1)); - - for (uint32_t i = 0; i < parts.size(); i++) { - AnimationPart &part = parts[i]; - entry = nullptr; - char search[256]; - snprintf(search, sizeof(search), "%s/", part.path); - while ((entry = reader.GetNextEntry(entry))) { - string name = reader.GetEntryName(entry); - if (name.find(search) || - !entry->GetDataSize() || - name.length() >= 256) - continue; - - part.frames.push_back(); - AnimationFrame &frame = part.frames.back(); - strcpy(frame.path, name.c_str()); - frame.file = reader.GetLocalEntry(entry); - } - - sort(part.frames.begin(), part.frames.end()); - } - - uint32_t frameDelayUs = 1000000 / fps; - - for (uint32_t i = 0; i < parts.size(); i++) { - AnimationPart &part = parts[i]; - - uint32_t j = 0; - while (sRunAnimation && (!part.count || j++ < part.count)) { - for (uint32_t k = 0; k < part.frames.size(); k++) { - struct timeval tv1, tv2; - gettimeofday(&tv1, nullptr); - AnimationFrame &frame = part.frames[k]; - if (!frame.buf) { - frame.ReadPngFrame(format); - } - - ANativeWindowBuffer *buf; - if (window->dequeueBuffer(window, &buf)) { - LOGW("Failed to get an ANativeWindowBuffer"); - break; - } - if (window->lockBuffer(window, buf)) { - LOGW("Failed to lock ANativeWindowBuffer"); - window->queueBuffer(window, buf); - break; - } - - void *vaddr; - if (grmodule->lock(grmodule, buf->handle, - GRALLOC_USAGE_SW_READ_NEVER | - GRALLOC_USAGE_SW_WRITE_OFTEN | - GRALLOC_USAGE_HW_FB, - 0, 0, width, height, &vaddr)) { - LOGW("Failed to lock buffer_handle_t"); - window->queueBuffer(window, buf); - break; - } - memcpy(vaddr, frame.buf, - frame.width * frame.height * frame.bytepp); - grmodule->unlock(grmodule, buf->handle); - - gettimeofday(&tv2, nullptr); - - timersub(&tv2, &tv1, &tv2); - - if (tv2.tv_usec < frameDelayUs) { - usleep(frameDelayUs - tv2.tv_usec); - } else { - LOGW("Frame delay is %d us but decoding took %d us", frameDelayUs, tv2.tv_usec); - } - - window->queueBuffer(window, buf); - - if (part.count && j >= part.count) { - free(frame.buf); - frame.buf = nullptr; - } - } - usleep(frameDelayUs * part.pause); - } - } - - return nullptr; -} - -static int -CancelBufferNoop(ANativeWindow* aWindow, android_native_buffer_t* aBuffer) -{ - return 0; -} - -__attribute__ ((visibility ("default"))) -FramebufferNativeWindow* -NativeWindow() -{ - if (gNativeWindow.get()) { - return gNativeWindow.get(); - } - - // Some gralloc HALs need this in order to open the - // framebuffer device after we restart with the screen off. - // - // NB: this *must* run BEFORE allocating the - // FramebufferNativeWindow. Do not separate these two C++ - // statements. - set_screen_state(1); - - // For some devices, it takes a while for the framebuffer to become - // usable. So we wait until the framebuffer has woken up before we - // try to open it. - { - char buf; - int len = 0; - ScopedClose fd(open("/sys/power/wait_for_fb_wake", O_RDONLY, 0)); - do { - len = read(fd.get(), &buf, 1); - } while (len < 0 && errno == EINTR); - if (len < 0) { - LOGE("BootAnimation: wait_for_fb_sleep failed errno: %d", errno); - } - } - - // We (apparently) don't have a way to tell if allocating the - // fbs succeeded or failed. - gNativeWindow = new FramebufferNativeWindow(); - - // Bug 776742: FrambufferNativeWindow doesn't set the cancelBuffer - // function pointer, causing EGL to segfault when the window surface - // is destroyed (i.e. on process exit). This workaround stops us - // from hard crashing in that situation. - gNativeWindow->cancelBuffer = CancelBufferNoop; - - sRunAnimation = true; - pthread_create(&sAnimationThread, nullptr, AnimationThread, nullptr); - - return gNativeWindow.get(); -} - - -__attribute__ ((visibility ("default"))) -void -StopBootAnimation() -{ - if (sRunAnimation) { - sRunAnimation = false; - pthread_join(sAnimationThread, nullptr); - } -}
deleted file mode 100644 --- a/b2g/app/BootAnimation.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef BOOTANIMATION_H -#define BOOTANIMATION_H - -namespace android { -class FramebufferNativeWindow; -} - -/* This returns a FramebufferNativeWindow if one exists. - * If not, one is created and the boot animation is started. */ -__attribute__ ((weak)) -android::FramebufferNativeWindow* NativeWindow(); - -/* This stops the boot animation if it's still running. */ -__attribute__ ((weak)) -void StopBootAnimation(); - -#endif /* BOOTANIMATION_H */
--- a/b2g/app/Makefile.in +++ b/b2g/app/Makefile.in @@ -17,27 +17,34 @@ ifdef ENABLE_MARIONETTE DEFINES += -DENABLE_MARIONETTE=1 endif ifndef LIBXUL_SDK CPPSRCS = nsBrowserApp.cpp ifeq (gonk,$(MOZ_WIDGET_TOOLKIT)) -CPPSRCS += BootAnimation.cpp LIBS += \ -lui \ + -lEGL \ -lhardware_legacy \ -lhardware \ -lcutils \ $(DEPTH)/media/libpng/$(LIB_PREFIX)mozpng.$(LIB_SUFFIX) \ + $(DEPTH)/widget/gonk/libdisplay/$(LIB_PREFIX)display.$(LIB_SUFFIX) \ $(MOZ_ZLIB_LIBS) \ $(NULL) +ifeq (17,$(ANDROID_VERSION)) +LIBS += \ + -lgui \ + -lsuspend \ + $(NULL) +endif OS_LDFLAGS += -Wl,--export-dynamic -LOCAL_INCLUDES += -I$(ANDROID_SOURCE)/hardware/libhardware_legacy/include +LOCAL_INCLUDES += -I$(topsrcdir)/widget/gonk/libdisplay endif LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/base LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/build LOCAL_INCLUDES += -I$(DEPTH)/build DEFINES += -DXPCOM_GLUE
--- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -380,46 +380,50 @@ pref("dom.ipc.browser_frames.oop_by_defa // Temporary permission hack for WebSMS pref("dom.sms.enabled", true); pref("dom.sms.strict7BitEncoding", false); // Disabled by default. pref("dom.sms.requestStatusReport", true); // Enabled by default. // Temporary permission hack for WebContacts pref("dom.mozContacts.enabled", true); +pref("dom.navigator-property.disable.mozContacts", false); +pref("dom.global-constructor.disable.mozContact", false); // WebAlarms pref("dom.mozAlarms.enabled", true); // SimplePush pref("services.push.enabled", true); // serverURL to be assigned by services team pref("services.push.serverURL", ""); pref("services.push.userAgentID", ""); -// exponential back-off start is 5 seconds like in HTTP/1.1 +// Exponential back-off start is 5 seconds like in HTTP/1.1. +// Maximum back-off is pingInterval. pref("services.push.retryBaseInterval", 5000); -// WebSocket level ping transmit interval in seconds. -pref("services.push.websocketPingInterval", 55); -// exponential back-off end is 20 minutes -pref("services.push.maxRetryInterval", 1200000); +// Interval at which to ping PushServer to check connection status. In +// milliseconds. If no reply is received within requestTimeout, the connection +// is considered closed. +pref("services.push.pingInterval", 1800000); // 30 minutes // How long before a DOMRequest errors as timeout pref("services.push.requestTimeout", 10000); // enable udp wakeup support pref("services.push.udp.wakeupEnabled", true); // port on which UDP server socket is bound pref("services.push.udp.port", 2442); // NetworkStats #ifdef MOZ_B2G_RIL pref("dom.mozNetworkStats.enabled", true); pref("ril.lastKnownMcc", "724"); #endif // WebSettings pref("dom.mozSettings.enabled", true); +pref("dom.navigator-property.disable.mozSettings", false); pref("dom.mozPermissionSettings.enabled", true); // controls if we want camera support pref("device.camera.enabled", true); pref("media.realtime_decoder.enabled", true); // TCPSocket pref("dom.mozTCPSocket.enabled", true);
--- a/b2g/app/nsBrowserApp.cpp +++ b/b2g/app/nsBrowserApp.cpp @@ -25,17 +25,17 @@ #ifdef XP_WIN // we want a wmain entry point #include "nsWindowsWMain.cpp" #define snprintf _snprintf #define strcasecmp _stricmp #endif #ifdef MOZ_WIDGET_GONK -#include "BootAnimation.h" +#include "GonkDisplay.h" #endif #include "BinaryPath.h" #include "nsXPCOMPrivate.h" // for MAXPATHLEN and XPCOM_DLL #ifdef MOZ_WIDGET_GONK # include <binder/ProcessState.h> @@ -145,17 +145,17 @@ static int do_main(int argc, char* argv[ } argv[2] = argv[0]; argv += 2; argc -= 2; } #ifdef MOZ_WIDGET_GONK /* Called to start the boot animation */ - (void) NativeWindow(); + (void) mozilla::GetGonkDisplay(); #endif if (appini) { nsXREAppData *appData; rv = XRE_CreateAppData(appini, &appData); if (NS_FAILED(rv)) { Output("Couldn't read application.ini"); return 255;
--- a/b2g/chrome/content/forms.js +++ b/b2g/chrome/content/forms.js @@ -183,16 +183,17 @@ let FormAssistant = { addEventListener("focus", this, true, false); addEventListener("blur", this, true, false); addEventListener("resize", this, true, false); addEventListener("submit", this, true, false); addEventListener("pagehide", this, true, false); addEventListener("beforeunload", this, true, false); addEventListener("input", this, true, false); addEventListener("keydown", this, true, false); + addEventListener("keyup", this, true, false); addMessageListener("Forms:Select:Choice", this); addMessageListener("Forms:Input:Value", this); addMessageListener("Forms:Select:Blur", this); addMessageListener("Forms:SetSelectionRange", this); }, ignoredInputTypes: new Set([ 'button', 'file', 'checkbox', 'radio', 'reset', 'submit', 'image' @@ -256,16 +257,17 @@ let FormAssistant = { get documentEncoder() { return this._documentEncoder; }, // Implements nsIEditorObserver get notification when the text content of // current input field has changed. EditAction: function fa_editAction() { if (this._editing) { + this._editing = false; return; } this.sendKeyboardState(this.focusedElement); }, handleEvent: function fa_handleEvent(evt) { let target = evt.target; @@ -354,22 +356,25 @@ let FormAssistant = { this.updateSelection(); break; case "keydown": // Don't monitor the text change resulting from key event. this._editing = true; // We use 'setTimeout' to wait until the input element accomplishes the - // change in selection range or text content. + // change in selection range. content.setTimeout(function() { this.updateSelection(); - this._editing = false; }.bind(this), 0); break; + + case "keyup": + this._editing = false; + break; } }, receiveMessage: function fa_receiveMessage(msg) { let target = this.focusedElement; if (!target) { return; }
--- a/b2g/chrome/content/runapp.js +++ b/b2g/chrome/content/runapp.js @@ -26,17 +26,19 @@ window.addEventListener('load', function return; } runAppObj = new AppRunner(appname); Services.obs.addObserver(runAppObj, 'browser-ui-startup-complete', false); }); window.addEventListener('unload', function() { - Services.obs.removeObserver(runAppObj, 'browser-ui-startup-complete'); + if (runAppObj) { + Services.obs.removeObserver(runAppObj, 'browser-ui-startup-complete'); + } }); function AppRunner(aName) { this._req = null; this._appName = aName; } AppRunner.prototype = { observe: function(aSubject, aTopic, aData) {
--- a/b2g/components/test/Makefile.in +++ b/b2g/components/test/Makefile.in @@ -8,11 +8,9 @@ DEPTH = @DEPTH@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ relativesrcdir = @relativesrcdir@ FAIL_ON_WARNINGS := 1 include $(DEPTH)/config/autoconf.mk -DISABLED_XPCSHELL_TESTS = unit - include $(topsrcdir)/config/rules.mk
--- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -347,18 +347,16 @@ ; JavaScript components @BINPATH@/components/ConsoleAPI.manifest @BINPATH@/components/ConsoleAPI.js @BINPATH@/components/BrowserElementParent.manifest @BINPATH@/components/BrowserElementParent.js @BINPATH@/components/ContactManager.js @BINPATH@/components/ContactManager.manifest -@BINPATH@/components/NavigatorPropertyHelper.js -@BINPATH@/components/NavigatorPropertyHelper.manifest @BINPATH@/components/PermissionSettings.js @BINPATH@/components/PermissionSettings.manifest @BINPATH@/components/PermissionPromptService.js @BINPATH@/components/PermissionPromptService.manifest @BINPATH@/components/AlarmsManager.js @BINPATH@/components/AlarmsManager.manifest @BINPATH@/components/FeedProcessor.manifest @BINPATH@/components/FeedProcessor.js
--- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -574,21 +574,28 @@ pref("browser.xul.error_pages.expert_bad // Work Offline is best manually managed by the user. pref("network.manage-offline-status", false); // We want to make sure mail URLs are handled externally... pref("network.protocol-handler.external.mailto", true); // for mail pref("network.protocol-handler.external.news", true); // for news pref("network.protocol-handler.external.snews", true); // for secure news pref("network.protocol-handler.external.nntp", true); // also news +#ifdef XP_WIN +pref("network.protocol-handler.external.ms-windows-store", true); +#endif + // ...without warning dialogs pref("network.protocol-handler.warn-external.mailto", false); pref("network.protocol-handler.warn-external.news", false); pref("network.protocol-handler.warn-external.snews", false); pref("network.protocol-handler.warn-external.nntp", false); +#ifdef XP_WIN +pref("network.protocol-handler.warn-external.ms-windows-store", false); +#endif // By default, all protocol handlers are exposed. This means that // the browser will respond to openURL commands for all URL types. // It will also try to open link clicks inside the browser before // failing over to the system handlers. pref("network.protocol-handler.expose-all", true); pref("network.protocol-handler.expose.mailto", false); pref("network.protocol-handler.expose.news", false);
--- a/browser/base/content/browser-places.js +++ b/browser/base/content/browser-places.js @@ -616,18 +616,18 @@ HistoryMenu.prototype = { let otherTabsCount = undoItem.tabs.length - 1; let label = (otherTabsCount == 0) ? menuLabelStringSingleTab : PluralForm.get(otherTabsCount, menuLabelString); let menuLabel = label.replace("#1", undoItem.title) .replace("#2", otherTabsCount); let m = document.createElement("menuitem"); m.setAttribute("label", menuLabel); let selectedTab = undoItem.tabs[undoItem.selected - 1]; - if (selectedTab.attributes.image) { - let iconURL = selectedTab.attributes.image; + if (selectedTab.image) { + let iconURL = selectedTab.image; // don't initiate a connection just to fetch a favicon (see bug 467828) if (/^https?:/.test(iconURL)) iconURL = "moz-anno:favicon:" + iconURL; m.setAttribute("image", iconURL); } m.setAttribute("class", "menuitem-iconic bookmark-item menuitem-with-favicon"); m.setAttribute("oncommand", "undoCloseWindow(" + i + ");");
--- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -471,17 +471,17 @@ nsContextMenu.prototype = { initClickToPlayItems: function() { this.showItem("context-ctp-play", this.onCTPPlugin); this.showItem("context-ctp-hide", this.onCTPPlugin); this.showItem("context-sep-ctp", this.onCTPPlugin); }, inspectNode: function CM_inspectNode() { - let {devtools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {}); + let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); let gBrowser = this.browser.ownerDocument.defaultView.gBrowser; let tt = devtools.TargetFactory.forTab(gBrowser.selectedTab); return gDevTools.showToolbox(tt, "inspector").then(function(toolbox) { let inspector = toolbox.getCurrentPanel(); inspector.selection.setNode(this.target, "browser-context-menu"); }.bind(this)); },
--- a/browser/components/dirprovider/tests/Makefile.in +++ b/browser/components/dirprovider/tests/Makefile.in @@ -5,11 +5,9 @@ DEPTH = @DEPTH@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ relativesrcdir = @relativesrcdir@ include $(DEPTH)/config/autoconf.mk -DISABLED_XPCSHELL_TESTS = unit - include $(topsrcdir)/config/rules.mk
--- a/browser/components/downloads/test/Makefile.in +++ b/browser/components/downloads/test/Makefile.in @@ -5,11 +5,9 @@ DEPTH = @DEPTH@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ relativesrcdir = @relativesrcdir@ include $(DEPTH)/config/autoconf.mk -DISABLED_XPCSHELL_TESTS = unit - include $(topsrcdir)/config/rules.mk
--- a/browser/components/feeds/test/Makefile.in +++ b/browser/components/feeds/test/Makefile.in @@ -5,19 +5,18 @@ DEPTH = @DEPTH@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ relativesrcdir = @relativesrcdir@ include $(DEPTH)/config/autoconf.mk -DISABLED_XPCSHELL_TESTS = unit - -MOCHITEST_FILES = bug408328-data.xml \ +MOCHITEST_FILES = \ + bug408328-data.xml \ bug368464-data.xml \ test_bug494328.html \ bug494328-data.xml \ test_bug589543.html \ bug589543-data.xml \ test_bug436801.html \ bug436801-data.xml \ test_registerHandler.html \
--- a/browser/components/migration/tests/Makefile.in +++ b/browser/components/migration/tests/Makefile.in @@ -5,11 +5,9 @@ DEPTH = @DEPTH@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ relativesrcdir = @relativesrcdir@ include $(DEPTH)/config/autoconf.mk -DISABLED_XPCSHELL_TESTS = unit - include $(topsrcdir)/config/rules.mk
--- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -163,17 +163,17 @@ BrowserGlue.prototype = { // nsIObserver implementation observe: function BG_observe(subject, topic, data) { switch (topic) { case "prefservice:after-app-defaults": this._onAppDefaults(); break; case "final-ui-startup": - this._onProfileStartup(); + this._finalUIStartup(); break; case "browser-delayed-startup-finished": this._onFirstWindowLoaded(); Services.obs.removeObserver(this, "browser-delayed-startup-finished"); break; case "sessionstore-windows-restored": this._onWindowsRestored(); break; @@ -383,22 +383,23 @@ BrowserGlue.prototype = { os.removeObserver(this, "profile-before-change"); #ifdef MOZ_SERVICES_HEALTHREPORT os.removeObserver(this, "keyword-search"); #endif }, _onAppDefaults: function BG__onAppDefaults() { // apply distribution customizations (prefs) - // other customizations are applied in _onProfileStartup() + // other customizations are applied in _finalUIStartup() this._distributionCustomizer.applyPrefDefaults(); }, - // profile startup handler (contains profile initialization routines) - _onProfileStartup: function BG__onProfileStartup() { + // runs on startup, before the first command line handler is invoked + // (i.e. before the first window is opened) + _finalUIStartup: function BG__finalUIStartup() { this._sanitizer.onStartup(); // check if we're in safe mode if (Services.appinfo.inSafeMode) { Services.ww.openWindow(null, "chrome://browser/content/safeMode.xul", "_blank", "chrome,centerscreen,modal,resizable=no", null); } // apply distribution customizations
--- a/browser/components/places/tests/Makefile.in +++ b/browser/components/places/tests/Makefile.in @@ -6,11 +6,9 @@ DEPTH = @DEPTH@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ relativesrcdir = @relativesrcdir@ include $(DEPTH)/config/autoconf.mk -DISABLED_XPCSHELL_TESTS = unit - include $(topsrcdir)/config/rules.mk
--- a/browser/components/sessionstore/src/SessionStore.jsm +++ b/browser/components/sessionstore/src/SessionStore.jsm @@ -243,20 +243,16 @@ Object.freeze(SessionStore); let SessionStoreInternal = { QueryInterface: XPCOMUtils.generateQI([ Ci.nsIDOMEventListener, Ci.nsIObserver, Ci.nsISupportsWeakReference ]), - // xul:tab attributes to (re)store (extensions might want to hook in here); - // the favicon is always saved for the about:sessionrestore page - xulAttributes: {"image": true}, - // set default load state _loadState: STATE_STOPPED, // During the initial restore and setBrowserState calls tracks the number of // windows yet to be restored _restoreCount: -1, // whether a setBrowserState call is in progress @@ -1295,17 +1291,17 @@ let SessionStoreInternal = { if (this._shouldSaveTabState(tabState)) { let tabTitle = aTab.label; let tabbrowser = aWindow.gBrowser; tabTitle = this._replaceLoadingTitle(tabTitle, tabbrowser, aTab); this._windows[aWindow.__SSi]._closedTabs.unshift({ state: tabState, title: tabTitle, - image: aTab.getAttribute("image"), + image: tabbrowser.getIcon(aTab), pos: aTab._tPos }); var length = this._windows[aWindow.__SSi]._closedTabs.length; if (length > this._max_tabs_undo) this._windows[aWindow.__SSi]._closedTabs.splice(this._max_tabs_undo, length - this._max_tabs_undo); } }, @@ -1691,21 +1687,19 @@ let SessionStoreInternal = { } } if (deleteFrom && deleteFrom[aKey]) delete deleteFrom[aKey]; }, persistTabAttribute: function ssi_persistTabAttribute(aName) { - if (aName in this.xulAttributes) - return; // this attribute is already being tracked - - this.xulAttributes[aName] = true; - this.saveStateDelayed(); + if (TabAttributes.persist(aName)) { + this.saveStateDelayed(); + } }, /** * Restores the session state stored in _lastSessionState. This will attempt * to merge data into the current session. If a window was opened at startup * with pinned tab(s), then the remaining data from the previous session for * that window will be opened into that winddow. Otherwise new windows will * be opened. @@ -1985,21 +1979,22 @@ let SessionStoreInternal = { for (let cap of gDocShellCapabilities(browser.docShell)) if (!browser.docShell["allow" + cap]) disallow.push(cap); if (disallow.length > 0) tabData.disallow = disallow.join(","); else if (tabData.disallow) delete tabData.disallow; - tabData.attributes = {}; - for (let name in this.xulAttributes) { - if (aTab.hasAttribute(name)) - tabData.attributes[name] = aTab.getAttribute(name); - } + // Save tab attributes. + tabData.attributes = TabAttributes.get(aTab); + + // Store the tab icon. + let tabbrowser = aTab.ownerDocument.defaultView.gBrowser; + tabData.image = tabbrowser.getIcon(aTab); if (aTab.__SS_extdata) tabData.extData = aTab.__SS_extdata; else if (tabData.extData) delete tabData.extData; if (history && browser.docShell instanceof Ci.nsIDocShell) { let storageData = SessionStorage.serialize(browser.docShell, aFullData) @@ -2978,18 +2973,20 @@ let SessionStoreInternal = { else tabbrowser.unpinTab(tab); if (tabData.hidden) tabbrowser.hideTab(tab); else tabbrowser.showTab(tab); - for (let name in tabData.attributes) - this.xulAttributes[name] = true; + if ("attributes" in tabData) { + // Ensure that we persist tab attributes restored from previous sessions. + Object.keys(tabData.attributes).forEach(a => TabAttributes.persist(a)); + } // keep the data around to prevent dataloss in case // a tab gets closed before it's been properly restored RestoringTabsData.set(browser, tabData); browser.__SS_restoreState = TAB_STATE_NEEDS_RESTORE; browser.setAttribute("pending", "true"); tab.setAttribute("pending", "true"); @@ -3102,20 +3099,25 @@ let SessionStoreInternal = { aIdMap, aDocIdentMap), true); } // make sure to reset the capabilities and attributes, in case this tab gets reused let disallow = new Set(tabData.disallow && tabData.disallow.split(",")); for (let cap of gDocShellCapabilities(browser.docShell)) browser.docShell["allow" + cap] = !disallow.has(cap); - for (let name in this.xulAttributes) - tab.removeAttribute(name); - for (let name in tabData.attributes) - tab.setAttribute(name, tabData.attributes[name]); + // Restore tab attributes. + if ("attributes" in tabData) { + TabAttributes.set(tab, tabData.attributes); + } + + // Restore the tab icon. + if ("image" in tabData) { + aWindow.gBrowser.setIcon(tab, tabData.image); + } if (tabData.storage && browser.docShell instanceof Ci.nsIDocShell) SessionStorage.deserialize(browser.docShell, tabData.storage); // notify the tabbrowser that the tab chrome has been restored var event = aWindow.document.createEvent("Events"); event.initEvent("SSTabRestoring", true, false); tab.dispatchEvent(event); @@ -4617,16 +4619,62 @@ let DyingWindowCache = { this._data.set(window, data); }, remove: function (window) { this._data.delete(window); } }; +// A set of tab attributes to persist. We will read a given list of tab +// attributes when collecting tab data and will re-set those attributes when +// the given tab data is restored to a new tab. +let TabAttributes = { + _attrs: new Set(), + + // We never want to directly read or write those attributes. + // 'image' should not be accessed directly but handled by using the + // gBrowser.getIcon()/setIcon() methods. + // 'pending' is used internal by sessionstore and managed accordingly. + _skipAttrs: new Set(["image", "pending"]), + + persist: function (name) { + if (this._attrs.has(name) || this._skipAttrs.has(name)) { + return false; + } + + this._attrs.add(name); + return true; + }, + + get: function (tab) { + let data = {}; + + for (let name of this._attrs) { + if (tab.hasAttribute(name)) { + data[name] = tab.getAttribute(name); + } + } + + return data; + }, + + set: function (tab, data = {}) { + // Clear attributes. + for (let name of this._attrs) { + tab.removeAttribute(name); + } + + // Set attributes. + for (let name in data) { + tab.setAttribute(name, data[name]); + } + } +}; + // This is used to help meter the number of restoring tabs. This is the control // point for telling the next tab to restore. It gets attached to each gBrowser // via gBrowser.addTabsProgressListener let gRestoreTabsProgressListener = { onStateChange: function(aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) { // Ignore state changes on browsers that we've already restored and state // changes that aren't applicable. if (aBrowser.__SS_restoreState &&
--- a/browser/components/sessionstore/test/Makefile.in +++ b/browser/components/sessionstore/test/Makefile.in @@ -10,22 +10,19 @@ relativesrcdir = @relativesrcdir@ include $(DEPTH)/config/autoconf.mk # browser_506482.js is disabled because of frequent failures (bug 538672) # browser_526613.js is disabled because of frequent failures (bug 534489) # browser_589246.js is disabled for leaking browser windows (bug 752467) # browser_580512.js is disabled for leaking browser windows (bug 752467) -DISABLED_XPCSHELL_TESTS = \ - unit \ - $(NULL) - MOCHITEST_BROWSER_FILES = \ head.js \ + browser_attributes.js \ browser_capabilities.js \ browser_dying_cache.js \ browser_form_restore_events.js \ browser_form_restore_events_sample.html \ browser_formdata_format.js \ browser_formdata_format_sample.html \ browser_input.js \ browser_input_sample.html \
new file mode 100644 --- /dev/null +++ b/browser/components/sessionstore/test/browser_attributes.js @@ -0,0 +1,72 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +function test() { + TestRunner.run(); +} + +/** + * This test makes sure that we correctly preserve tab attributes when storing + * and restoring tabs. It also ensures that we skip special attributes like + * 'image' and 'pending' that need to be handled differently or internally. + */ + +const PREF = "browser.sessionstore.restore_on_demand"; + +function runTests() { + Services.prefs.setBoolPref(PREF, true) + registerCleanupFunction(() => Services.prefs.clearUserPref(PREF)); + + // Add a new tab with a nice icon. + let tab = gBrowser.addTab("about:robots"); + yield whenBrowserLoaded(tab.linkedBrowser); + + // Check that the tab has an 'image' attribute. + ok(tab.hasAttribute("image"), "tab.image exists"); + + // Make sure we do not persist 'image' attributes. + ss.persistTabAttribute("image"); + let {attributes} = JSON.parse(ss.getTabState(tab)); + ok(!("image" in attributes), "'image' attribute not saved"); + ok(!("custom" in attributes), "'custom' attribute not saved"); + + // Test persisting a custom attribute. + tab.setAttribute("custom", "foobar"); + ss.persistTabAttribute("custom"); + + let {attributes} = JSON.parse(ss.getTabState(tab)); + is(attributes.custom, "foobar", "'custom' attribute is correct"); + + // Make sure we're backwards compatible and restore old 'image' attributes. + let state = { + entries: [{url: "about:mozilla"}], + attributes: {custom: "foobaz", image: gBrowser.getIcon(tab)} + }; + + // Prepare a pending tab waiting to be restored. + whenTabRestoring(tab); + yield ss.setTabState(tab, JSON.stringify(state)); + + ok(tab.hasAttribute("pending"), "tab is pending"); + is(gBrowser.getIcon(tab), state.attributes.image, "tab has correct icon"); + + // Let the pending tab load. + gBrowser.selectedTab = tab; + yield whenBrowserLoaded(tab.linkedBrowser); + + // Ensure no 'image' or 'pending' attributes are stored. + let {attributes} = JSON.parse(ss.getTabState(tab)); + ok(!("image" in attributes), "'image' attribute not saved"); + ok(!("pending" in attributes), "'pending' attribute not saved"); + is(attributes.custom, "foobaz", "'custom' attribute is correct"); + + // Clean up. + gBrowser.removeTab(tab); +} + +function whenTabRestoring(tab) { + tab.addEventListener("SSTabRestoring", function onRestoring() { + tab.removeEventListener("SSTabRestoring", onRestoring); + executeSoon(next); + }); +}
--- a/browser/components/shell/test/Makefile.in +++ b/browser/components/shell/test/Makefile.in @@ -5,16 +5,14 @@ DEPTH = @DEPTH@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ relativesrcdir = @relativesrcdir@ include $(DEPTH)/config/autoconf.mk -DISABLED_XPCSHELL_TESTS = unit - - -MOCHITEST_BROWSER_FILES = browser_420786.js \ +MOCHITEST_BROWSER_FILES = \ + browser_420786.js \ browser_633221.js \ $(NULL) include $(topsrcdir)/config/rules.mk
--- a/browser/components/tabview/test/browser_tabview_bug610242.js +++ b/browser/components/tabview/test/browser_tabview_bug610242.js @@ -22,17 +22,17 @@ function onTabViewWindowLoaded(win) { let group = new contentWindow.GroupItem([], { bounds: box }); ok(group.isEmpty(), "This group is empty"); contentWindow.UI.setActive(group); is(contentWindow.GroupItems.getActiveGroupItem(), group, "new group is active"); // Create a bunch of tabs in the group let bg = {inBackground: true}; let datatext = win.gBrowser.loadOneTab("data:text/plain,bug610242", bg); - let datahtml = win.gBrowser.loadOneTab("data:text/html,<blink>don't blink!</blink>", bg); + let datahtml = win.gBrowser.loadOneTab("data:text/html,<h1>hi!</h1>", bg); let mozilla = win.gBrowser.loadOneTab("about:mozilla", bg); let synclog = win.gBrowser.loadOneTab("about:sync-log", bg); let html = win.gBrowser.loadOneTab("http://example.com", bg); let png = win.gBrowser.loadOneTab("http://mochi.test:8888/browser/browser/base/content/test/moz.png", bg); let svg = win.gBrowser.loadOneTab("http://mochi.test:8888/browser/browser/base/content/test/title_test.svg", bg); ok(!group.shouldStack(group._children.length), "Group should not stack.");
--- a/browser/devtools/commandline/BuiltinCommands.jsm +++ b/browser/devtools/commandline/BuiltinCommands.jsm @@ -17,17 +17,17 @@ Cu.import("resource://gre/modules/common Cu.import("resource://gre/modules/osfile.jsm") Cu.import("resource://gre/modules/devtools/gcli.jsm"); Cu.import("resource:///modules/devtools/shared/event-emitter.js"); XPCOMUtils.defineLazyModuleGetter(this, "gDevTools", "resource:///modules/devtools/gDevTools.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "devtools", - "resource:///modules/devtools/gDevTools.jsm"); + "resource://gre/modules/devtools/Loader.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "AppCacheUtils", "resource:///modules/devtools/AppCacheUtils.jsm"); /* CmdAddon ---------------------------------------------------------------- */ (function(module) { XPCOMUtils.defineLazyModuleGetter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm"); @@ -1923,17 +1923,17 @@ XPCOMUtils.defineLazyModuleGetter(this, const { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {}); /** * 'listen' command */ gcli.addCommand({ name: "listen", description: gcli.lookup("listenDesc"), - manual: gcli.lookup("listenManual"), + manual: gcli.lookupFormat("listenManual2", [BRAND_SHORT_NAME]), params: [ { name: "port", type: "number", get defaultValue() { return Services.prefs.getIntPref("devtools.debugger.chrome-debugging-port"); }, description: gcli.lookup("listenPortDesc"),
new file mode 100644 --- /dev/null +++ b/browser/devtools/commandline/gcli.jsm @@ -0,0 +1,20 @@ +/* + * Copyright 2012, Mozilla Foundation and contributors + * + * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +"use strict"; + +this.EXPORTED_SYMBOLS = [ "gcli" ]; +Components.utils.import("resource://gre/modules/devtools/gcli.jsm");
--- a/browser/devtools/commandline/test/helpers.js +++ b/browser/devtools/commandline/test/helpers.js @@ -19,17 +19,17 @@ this.EXPORTED_SYMBOLS = [ 'helpers' ]; var helpers = {}; this.helpers = helpers; let require = (Cu.import("resource://gre/modules/devtools/Require.jsm", {})).require; Components.utils.import("resource://gre/modules/devtools/gcli.jsm", {}); let console = (Cu.import("resource://gre/modules/devtools/Console.jsm", {})).console; -let TargetFactory = (Cu.import("resource:///modules/devtools/gDevTools.jsm", {})).devtools.TargetFactory; +let TargetFactory = (Cu.import("resource://gre/modules/devtools/Loader.jsm", {})).devtools.TargetFactory; let Promise = (Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", {})).Promise; let assert = { ok: ok, is: is, log: info }; var util = require('util/util'); var converters = require('gcli/converters');
--- a/browser/devtools/debugger/CmdDebugger.jsm +++ b/browser/devtools/debugger/CmdDebugger.jsm @@ -1,24 +1,27 @@ +/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ /* 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 { classes: Cc, interfaces: Ci, utils: Cu } = Components; + this.EXPORTED_SYMBOLS = [ ]; Cu.import("resource://gre/modules/devtools/gcli.jsm"); Cu.import('resource://gre/modules/XPCOMUtils.jsm'); XPCOMUtils.defineLazyModuleGetter(this, "gDevTools", - "resource:///modules/devtools/gDevTools.jsm"); + "resource:///modules/devtools/gDevTools.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "console", - "resource://gre/modules/devtools/Console.jsm"); - + "resource://gre/modules/devtools/Console.jsm"); /** * 'break' command */ gcli.addCommand({ name: "break", description: gcli.lookup("breakDesc"), manual: gcli.lookup("breakManual") @@ -27,18 +30,18 @@ gcli.addCommand({ /** * 'break list' command */ gcli.addCommand({ name: "break list", description: gcli.lookup("breaklistDesc"), returnType: "breakpoints", exec: function(args, context) { - let panel = getPanel(context, "jsdebugger", {ensure_opened: true}); - return panel.then(function(dbg) { + let dbg = getPanel(context, "jsdebugger", { ensure_opened: true }); + return dbg.then(function(dbg) { let breakpoints = []; for (let source in dbg.panelWin.DebuggerView.Sources) { for (let { attachment: breakpoint } in source) { breakpoints.push({ url: source.value, label: source.label, lineNumber: breakpoint.lineNumber, lineText: breakpoint.lineText @@ -101,18 +104,18 @@ var breakListHtml = "" + " <td class='gcli-breakpoint-label'>${breakpoint.label}</td>" + " <td class='gcli-breakpoint-lineText'>" + " ${breakpoint.truncatedLineText}" + " </td>" + " <td>" + " <span class='gcli-out-shortcut'" + " data-command='break del ${breakpoint.index}'" + " onclick='${onclick}'" + - " ondblclick='${ondblclick}'" + - " >" + gcli.lookup("breaklistOutRemove") + "</span>" + + " ondblclick='${ondblclick}'>" + + " " + gcli.lookup("breaklistOutRemove") + "</span>" + " </td>" + " </tr>" + " </tbody>" + "</table>" + ""; var MAX_LINE_TEXT_LENGTH = 30; var MAX_LABEL_LENGTH = 20; @@ -133,25 +136,21 @@ gcli.addCommand({ name: "break add line", description: gcli.lookup("breakaddlineDesc"), params: [ { name: "file", type: { name: "selection", data: function(args, context) { - let files = []; let dbg = getPanel(context, "jsdebugger"); if (dbg) { - let sourcesView = dbg.panelWin.DebuggerView.Sources; - for (let item in sourcesView) { - files.push(item.value); - } + return dbg.panelWin.DebuggerView.Sources.values; } - return files; + return []; } }, description: gcli.lookup("breakaddlineFileDesc") }, { name: "line", type: { name: "number", min: 1, step: 10 }, description: gcli.lookup("breakaddlineLineDesc") @@ -160,61 +159,59 @@ gcli.addCommand({ returnType: "string", exec: function(args, context) { args.type = "line"; let dbg = getPanel(context, "jsdebugger"); if (!dbg) { return gcli.lookup("debuggerStopped"); } - var deferred = context.defer(); + + let deferred = context.defer(); let position = { url: args.file, line: args.line }; dbg.addBreakpoint(position, function(aBreakpoint, aError) { if (aError) { deferred.resolve(gcli.lookupFormat("breakaddFailed", [aError])); return; } deferred.resolve(gcli.lookup("breakaddAdded")); }); return deferred.promise; } }); - /** * 'break del' command */ gcli.addCommand({ name: "break del", description: gcli.lookup("breakdelDesc"), params: [ { - name: "breakid", + name: "breakIndex", type: { name: "number", min: 0, max: function(args, context) { let dbg = getPanel(context, "jsdebugger"); - return dbg == null ? - null : - Object.keys(dbg.getAllBreakpoints()).length - 1; + return dbg == null ? 0 : Object.keys(dbg.getAllBreakpoints()).length - 1; }, }, description: gcli.lookup("breakdelBreakidDesc") } ], returnType: "string", exec: function(args, context) { let dbg = getPanel(context, "jsdebugger"); if (!dbg) { return gcli.lookup("debuggerStopped"); } let breakpoints = dbg.getAllBreakpoints(); - let id = Object.keys(breakpoints)[args.breakid]; + let id = Object.keys(breakpoints)[args.breakIndex]; if (!id || !(id in breakpoints)) { return gcli.lookup("breakNotFound"); } let deferred = context.defer(); try { dbg.removeBreakpoint(breakpoints[id], function() { deferred.resolve(gcli.lookup("breakdelRemoved")); @@ -239,29 +236,29 @@ gcli.addCommand({ /** * 'dbg open' command */ gcli.addCommand({ name: "dbg open", description: gcli.lookup("dbgOpen"), params: [], exec: function(args, context) { - return gDevTools.showToolbox(context.environment.target, "jsdebugger").then(function() null); + return gDevTools.showToolbox(context.environment.target, "jsdebugger").then(() => null); } }); /** * 'dbg close' command */ gcli.addCommand({ name: "dbg close", description: gcli.lookup("dbgClose"), params: [], exec: function(args, context) { - return gDevTools.closeToolbox(context.environment.target).then(function() null); + return gDevTools.closeToolbox(context.environment.target).then(() => null); } }); /** * 'dbg interrupt' command */ gcli.addCommand({ name: "dbg interrupt", @@ -383,16 +380,17 @@ gcli.addCommand({ params: [], returnType: "dom", exec: function(args, context) { let dbg = getPanel(context, "jsdebugger"); let doc = context.environment.chromeDocument; if (!dbg) { return gcli.lookup("debuggerClosed"); } + let sources = dbg._view.Sources.values; let div = createXHTMLElement(doc, "div"); let ol = createXHTMLElement(doc, "ol"); sources.forEach(function(src) { let li = createXHTMLElement(doc, "li"); li.textContent = src; ol.appendChild(li); }); @@ -409,26 +407,24 @@ function createXHTMLElement(document, ta return document.createElementNS("http://www.w3.org/1999/xhtml", tagname); } /** * Helper to find the 'data-command' attribute and call some action on it. * @see |updateCommand()| and |executeCommand()| */ function withCommand(element, action) { - var command = element.getAttribute("data-command"); + let command = element.getAttribute("data-command"); if (!command) { - command = element.querySelector("*[data-command]") - .getAttribute("data-command"); + command = element.querySelector("*[data-command]").getAttribute("data-command"); } if (command) { action(command); - } - else { + } else { console.warn("Missing data-command for " + util.findCssSelector(element)); } } /** * Create a handler to update the requisition to contain the text held in the * first matching data-command attribute under the currentTarget of the event. * @param context Either a Requisition or an ExecutionContext or another object @@ -457,23 +453,27 @@ function createExecuteHandler(context) { }); }); } } /** * A helper to go from a command context to a debugger panel */ -function getPanel(context, id, opts) { +function getPanel(context, id, options = {}) { if (context == null) { return undefined; } let target = context.environment.target; - if (opts && opts.ensure_opened) { + if (options.ensure_opened) { return gDevTools.showToolbox(target, id).then(function(toolbox) { return toolbox.getPanel(id); }); } else { let toolbox = gDevTools.getToolbox(target); - return toolbox && toolbox.getPanel(id); + if (toolbox) { + return toolbox.getPanel(id); + } else { + return undefined; + } } }
--- a/browser/devtools/debugger/DebuggerPanel.jsm +++ b/browser/devtools/debugger/DebuggerPanel.jsm @@ -13,17 +13,17 @@ Cu.import("resource://gre/modules/XPCOMU Cu.import("resource:///modules/devtools/shared/event-emitter.js"); XPCOMUtils.defineLazyModuleGetter(this, "Promise", "resource://gre/modules/commonjs/sdk/core/promise.js"); XPCOMUtils.defineLazyModuleGetter(this, "DebuggerServer", "resource://gre/modules/devtools/dbg-server.jsm"); -function DebuggerPanel(iframeWindow, toolbox) { +this.DebuggerPanel = function DebuggerPanel(iframeWindow, toolbox) { this.panelWin = iframeWindow; this._toolbox = toolbox; this._view = this.panelWin.DebuggerView; this._controller = this.panelWin.DebuggerController; this._controller._target = this.target; this._bkp = this._controller.Breakpoints; @@ -80,10 +80,10 @@ DebuggerPanel.prototype = { }, getBreakpoint: function() { return this._bkp.getBreakpoint.apply(this._bkp, arguments); }, getAllBreakpoints: function() { return this._bkp.store; - }, + } };
--- a/browser/devtools/debugger/DebuggerUI.jsm +++ b/browser/devtools/debugger/DebuggerUI.jsm @@ -34,34 +34,34 @@ this.DebuggerUI = function DebuggerUI(aW this.listenToTabs(); }; DebuggerUI.prototype = { /** * Update the status of tool's menuitems and buttons when * the user switches tabs. */ - listenToTabs: function DUI_listenToTabs() { + listenToTabs: function() { let win = this.chromeWindow; let tabs = win.gBrowser.tabContainer; let bound_refreshCommand = this.refreshCommand.bind(this); tabs.addEventListener("TabSelect", bound_refreshCommand, true); win.addEventListener("unload", function onClose(aEvent) { win.removeEventListener("unload", onClose, false); tabs.removeEventListener("TabSelect", bound_refreshCommand, true); }, false); }, /** * Called by the DebuggerPane to update the Debugger toggle switches with the * debugger state. */ - refreshCommand: function DUI_refreshCommand() { + refreshCommand: function() { let scriptDebugger = this.getDebugger(); let command = this.chromeWindow.document.getElementById("Tools:Debugger"); let selectedTab = this.chromeWindow.gBrowser.selectedTab; if (scriptDebugger && scriptDebugger.ownerTab === selectedTab) { command.setAttribute("checked", "true"); } else { command.setAttribute("checked", "false"); @@ -69,66 +69,66 @@ DebuggerUI.prototype = { }, /** * Starts a debugger for the current tab, or stops it if already started. * * @return DebuggerPane | null * The script debugger instance if it's started, null if stopped. */ - toggleDebugger: function DUI_toggleDebugger() { + toggleDebugger: function() { let scriptDebugger = this.findDebugger(); let selectedTab = this.chromeWindow.gBrowser.selectedTab; if (scriptDebugger) { scriptDebugger.close(); return null; } return new DebuggerPane(this, selectedTab); }, /** * Starts a remote debugger in a new window, or stops it if already started. * * @return RemoteDebuggerWindow | null * The remote debugger instance if it's started, null if stopped. */ - toggleRemoteDebugger: function DUI_toggleRemoteDebugger() { + toggleRemoteDebugger: function() { let remoteDebugger = this.getRemoteDebugger(); if (remoteDebugger) { remoteDebugger.close(); return null; } return new RemoteDebuggerWindow(this); }, /** * Starts a chrome debugger in a new process, or stops it if already started. * * @return ChromeDebuggerProcess | null * The chrome debugger instance if it's started, null if stopped. */ - toggleChromeDebugger: function DUI_toggleChromeDebugger(aOnClose, aOnRun) { + toggleChromeDebugger: function(aOnClose, aOnRun) { let chromeDebugger = this.getChromeDebugger(); if (chromeDebugger) { chromeDebugger.close(); return null; } return new ChromeDebuggerProcess(this, aOnClose, aOnRun); }, /** * Gets the current script debugger from any open window. * * @return DebuggerPane | null * The script debugger instance if it exists, null otherwise. */ - findDebugger: function DUI_findDebugger() { + findDebugger: function() { let enumerator = Services.wm.getEnumerator("navigator:browser"); while (enumerator.hasMoreElements()) { let chromeWindow = enumerator.getNext().QueryInterface(Ci.nsIDOMWindow); let scriptDebugger = chromeWindow.DebuggerUI.getDebugger(); if (scriptDebugger) { return scriptDebugger; } } @@ -136,74 +136,74 @@ DebuggerUI.prototype = { }, /** * Get the current script debugger. * * @return DebuggerPane | null * The script debugger instance if it exists, null otherwise. */ - getDebugger: function DUI_getDebugger() { + getDebugger: function() { return '_scriptDebugger' in this ? this._scriptDebugger : null; }, /** * Get the remote debugger for the current chrome window. * * @return RemoteDebuggerWindow | null * The remote debugger instance if it exists, null otherwise. */ - getRemoteDebugger: function DUI_getRemoteDebugger() { + getRemoteDebugger: function() { return '_remoteDebugger' in this ? this._remoteDebugger : null; }, /** * Get the chrome debugger for the current firefox instance. * * @return ChromeDebuggerProcess | null * The chrome debugger instance if it exists, null otherwise. */ - getChromeDebugger: function DUI_getChromeDebugger() { + getChromeDebugger: function() { return '_chromeDebugger' in this ? this._chromeDebugger : null; } }; /** * Creates a pane that will host the debugger. * * @param DebuggerUI aDebuggerUI * The parent instance creating the new debugger. * @param XULElement aTab * The tab in which to create the debugger. */ -function DebuggerPane(aDebuggerUI, aTab) { +this.DebuggerPane = function DebuggerPane(aDebuggerUI, aTab) { this.globalUI = aDebuggerUI; this._win = aDebuggerUI.chromeWindow; this._tab = aTab; this.close = this.close.bind(this); this._initServer(); this._create(); } DebuggerPane.prototype = { /** * Initializes the debugger server. */ - _initServer: function DP__initServer() { + _initServer: function() { if (!DebuggerServer.initialized) { DebuggerServer.init(); DebuggerServer.addBrowserActors(); } }, /** * Creates and initializes the widgets containing the debugger UI. */ - _create: function DP__create() { + _create: function() { this.globalUI._scriptDebugger = this; let gBrowser = this._win.gBrowser; let ownerDocument = gBrowser.parentNode.ownerDocument; this._splitter = ownerDocument.createElement("splitter"); this._splitter.setAttribute("class", "devtools-horizontal-splitter"); @@ -233,17 +233,17 @@ DebuggerPane.prototype = { /** * Closes the debugger, removing child nodes and event listeners. * * @param function aCloseCallback * Clients can pass a close callback to be notified when * the panel successfully closes. */ - close: function DP_close(aCloseCallback) { + close: function(aCloseCallback) { if (!this.globalUI) { return; } delete this.globalUI._scriptDebugger; // This method is also used as an event handler, so only // use aCloseCallback if it's a function. if (typeof aCloseCallback == "function") { @@ -300,29 +300,29 @@ DebuggerPane.prototype = { }; /** * Creates a window that will host a remote debugger. * * @param DebuggerUI aDebuggerUI * The parent instance creating the new debugger. */ -function RemoteDebuggerWindow(aDebuggerUI) { +this.RemoteDebuggerWindow = function RemoteDebuggerWindow(aDebuggerUI) { this.globalUI = aDebuggerUI; this._win = aDebuggerUI.chromeWindow; this.close = this.close.bind(this); this._create(); } RemoteDebuggerWindow.prototype = { /** * Creates and initializes the widgets containing the remote debugger UI. */ - _create: function DP__create() { + _create: function() { this.globalUI._remoteDebugger = this; this._dbgwin = this.globalUI.chromeWindow.open(DBG_XUL, L10N.getStr("remoteDebuggerWindowTitle"), "chrome,dependent,resizable"); let self = this; this._dbgwin.addEventListener("Debugger:Loaded", function dbgLoaded() { @@ -338,17 +338,17 @@ RemoteDebuggerWindow.prototype = { }, true); this._dbgwin._remoteFlag = true; }, /** * Closes the remote debugger, along with the parent window if necessary. */ - close: function DP_close() { + close: function() { if (!this.globalUI) { return; } delete this.globalUI._remoteDebugger; this._dbgwin.removeEventListener("Debugger:Unloaded", this.close, true); this._dbgwin.close(); this._dbgwin = null; @@ -385,43 +385,43 @@ RemoteDebuggerWindow.prototype = { * * @param DebuggerUI aDebuggerUI * The parent instance creating the new debugger. * @param function aOnClose * Optional, a function called when the process exits. * @param function aOnRun * Optional, a function called when the process starts running. */ -function ChromeDebuggerProcess(aDebuggerUI, aOnClose, aOnRun) { +this.ChromeDebuggerProcess = function ChromeDebuggerProcess(aDebuggerUI, aOnClose, aOnRun) { this.globalUI = aDebuggerUI; this._win = aDebuggerUI.chromeWindow; this._closeCallback = aOnClose; this._runCallback = aOnRun; this._initServer(); this._initProfile(); this._create(); } ChromeDebuggerProcess.prototype = { /** * Initializes the debugger server. */ - _initServer: function RDP__initServer() { + _initServer: function() { if (!DebuggerServer.initialized) { DebuggerServer.init(); DebuggerServer.addBrowserActors(); } DebuggerServer.openListener(Prefs.chromeDebuggingPort); }, /** * Initializes a profile for the remote debugger process. */ - _initProfile: function RDP__initProfile() { + _initProfile: function() { let profileService = Cc["@mozilla.org/toolkit/profile-service;1"] .createInstance(Ci.nsIToolkitProfileService); let profileName; try { // Attempt to get the required chrome debugging profile name string. profileName = profileService.selectedProfile.name + CHROME_DEBUGGER_PROFILE_NAME; } catch (e) { @@ -455,17 +455,17 @@ ChromeDebuggerProcess.prototype = { // Create a new chrome debugging profile. this._dbgProfile = profileService.createProfile(null, null, profileName); profileService.flush(); }, /** * Creates and initializes the profile & process for the remote debugger. */ - _create: function RDP__create() { + _create: function() { this.globalUI._chromeDebugger = this; let file = Services.dirsvc.get("XREExeF", Ci.nsIFile); dumpn("Initializing chrome debugging process"); let process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess); process.init(file); @@ -480,17 +480,17 @@ ChromeDebuggerProcess.prototype = { if (typeof this._runCallback == "function") { this._runCallback.call({}, this); } }, /** * Closes the remote debugger, removing the profile and killing the process. */ - close: function RDP_close() { + close: function() { dumpn("Closing chrome debugging process"); if (!this.globalUI) { dumpn("globalUI is missing"); return; } delete this.globalUI._chromeDebugger; if (this._dbgProcess.isRunning) { @@ -515,17 +515,17 @@ ChromeDebuggerProcess.prototype = { */ let L10N = { /** * L10N shortcut function. * * @param string aName * @return string */ - getStr: function L10N_getStr(aName) { + getStr: function(aName) { return this.stringBundle.GetStringFromName(aName); } }; XPCOMUtils.defineLazyGetter(L10N, "stringBundle", function() { return Services.strings.createBundle(DBG_STRINGS_URI); });
--- a/browser/devtools/debugger/debugger-controller.js +++ b/browser/devtools/debugger/debugger-controller.js @@ -1,18 +1,16 @@ /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ft=javascript ts=2 et sw=2 tw=80: */ /* 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 Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; +const { classes: Cc, interfaces: Ci, utils: Cu } = Components; const DBG_STRINGS_URI = "chrome://browser/locale/devtools/debugger.properties"; const NEW_SOURCE_IGNORED_URLS = ["debugger eval code", "self-hosted"]; const NEW_SOURCE_DISPLAY_DELAY = 200; // ms const FETCH_SOURCE_RESPONSE_DELAY = 50; // ms const FRAME_STEP_CLEAR_DELAY = 100; // ms const CALL_STACK_PAGE_SIZE = 25; // frames @@ -36,17 +34,17 @@ XPCOMUtils.defineLazyModuleGetter(this, /** * Object defining the debugger controller components. */ let DebuggerController = { /** * Initializes the debugger controller. */ - initialize: function DC_initialize() { + initialize: function() { dumpn("Initializing the DebuggerController"); this.startupDebugger = this.startupDebugger.bind(this); this.shutdownDebugger = this.shutdownDebugger.bind(this); this._onTabNavigated = this._onTabNavigated.bind(this); this._onTabDetached = this._onTabDetached.bind(this); // Chrome debugging lives in a different process and needs to handle @@ -58,17 +56,17 @@ let DebuggerController = { }, /** * Initializes the view. * * @return object * A promise that is resolved when the debugger finishes startup. */ - startupDebugger: function DC_startupDebugger() { + startupDebugger: function() { if (this._isInitialized) { return this._startup.promise; } this._isInitialized = true; window.removeEventListener("DOMContentLoaded", this.startupDebugger, true); let deferred = this._startup = Promise.defer(); @@ -87,17 +85,17 @@ let DebuggerController = { }, /** * Destroys the view and disconnects the debugger client from the server. * * @return object * A promise that is resolved when the debugger finishes shutdown. */ - shutdownDebugger: function DC__shutdownDebugger() { + shutdownDebugger: function() { if (this._isDestroyed) { return this._shutdown.promise; } this._isDestroyed = true; this._startup = null; window.removeEventListener("unload", this.shutdownDebugger, true); let deferred = this._shutdown = Promise.defer(); @@ -123,17 +121,17 @@ let DebuggerController = { * wiring event handlers as necessary. * * In case of a chrome debugger living in a different process, a socket * connection pipe is opened as well. * * @return object * A promise that is resolved when the debugger finishes connecting. */ - connect: function DC_connect() { + connect: function() { if (this._connection) { return this._connection.promise; } let deferred = this._connection = Promise.defer(); if (!window._isChromeDebugger) { let target = this._target; @@ -166,17 +164,17 @@ let DebuggerController = { }); return deferred.promise; }, /** * Disconnects the debugger client and removes event handlers as necessary. */ - disconnect: function DC_disconnect() { + disconnect: function() { // Return early if the client didn't even have a chance to instantiate. if (!this.client) { return; } // When debugging local or a remote instance, the connection is closed by // the RemoteTarget. if (window._isChromeDebugger) { @@ -193,17 +191,17 @@ let DebuggerController = { /** * Called for each location change in the debugged tab. * * @param string aType * Packet type. * @param object aPacket * Packet received from the server. */ - _onTabNavigated: function DC__onTabNavigated(aType, aPacket) { + _onTabNavigated: function(aType, aPacket) { if (aType == "will-navigate") { DebuggerView._handleTabNavigation(); // Discard all the old sources. DebuggerController.SourceScripts.clearCache(); DebuggerController.Parser.clearCache(); SourceUtils.clearCache(); return; @@ -212,31 +210,31 @@ let DebuggerController = { this.ThreadState._handleTabNavigation(); this.StackFrames._handleTabNavigation(); this.SourceScripts._handleTabNavigation(); }, /** * Called when the debugged tab is closed. */ - _onTabDetached: function DC__onTabDetached() { + _onTabDetached: function() { this.shutdownDebugger(); }, /** * Sets up a debugging session. * * @param DebuggerClient aClient * The debugger client. * @param string aThreadActor * The remote protocol grip of the tab. * @param function aCallback * A function to invoke once the client attached to the active thread. */ - _startDebuggingTab: function DC__startDebuggingTab(aClient, aThreadActor, aCallback) { + _startDebuggingTab: function(aClient, aThreadActor, aCallback) { if (!aClient) { Cu.reportError("No client found!"); return; } this.client = aClient; aClient.attachThread(aThreadActor, (aResponse, aThreadClient) => { if (!aThreadClient) { @@ -254,33 +252,33 @@ let DebuggerController = { aCallback(); } }, { useSourceMaps: Prefs.sourceMapsEnabled }); }, /** * Warn if resuming execution produced a wrongOrder error. */ - _ensureResumptionOrder: function DC__ensureResumptionOrder(aResponse) { + _ensureResumptionOrder: function(aResponse) { if (aResponse.error == "wrongOrder") { DebuggerView.Toolbar.showResumeWarning(aResponse.lastPausedUrl); } }, /** * Sets up a chrome debugging session. * * @param DebuggerClient aClient * The debugger client. * @param object aChromeDebugger * The remote protocol grip of the chrome debugger. * @param function aCallback * A function to invoke once the client attached to the active thread. */ - _startChromeDebugging: function DC__startChromeDebugging(aClient, aChromeDebugger, aCallback) { + _startChromeDebugging: function(aClient, aChromeDebugger, aCallback) { if (!aClient) { Cu.reportError("No client found!"); return; } this.client = aClient; aClient.attachThread(aChromeDebugger, (aResponse, aThreadClient) => { if (!aThreadClient) { @@ -299,17 +297,17 @@ let DebuggerController = { } }, { useSourceMaps: Prefs.sourceMapsEnabled }); }, /** * Detach and reattach to the thread actor with useSourceMaps true, blow * away old scripts and get sources again. */ - reconfigureThread: function DC_reconfigureThread(aUseSourceMaps) { + reconfigureThread: function(aUseSourceMaps) { this.client.reconfigureThread(aUseSourceMaps, (aResponse) => { if (aResponse.error) { let msg = "Couldn't reconfigure thread: " + aResponse.message; Cu.reportError(msg); dumpn(msg); return; } @@ -321,17 +319,17 @@ let DebuggerController = { this.activeThread._clearFrames(); this.activeThread.fillFrames(CALL_STACK_PAGE_SIZE); }); }, /** * Attempts to quit the current process if allowed. */ - _quitApp: function DC__quitApp() { + _quitApp: function() { let canceled = Cc["@mozilla.org/supports-PRBool;1"] .createInstance(Ci.nsISupportsPRBool); Services.obs.notifyObservers(canceled, "quit-application-requested", null); // Somebody canceled our quit request. if (canceled.data) { return; @@ -357,51 +355,51 @@ function ThreadState() { } ThreadState.prototype = { get activeThread() DebuggerController.activeThread, /** * Connect to the current thread client. */ - connect: function TS_connect() { + connect: function() { dumpn("ThreadState is connecting..."); this.activeThread.addListener("paused", this._update); this.activeThread.addListener("resumed", this._update); this.activeThread.pauseOnExceptions(Prefs.pauseOnExceptions); this._handleTabNavigation(); }, /** * Disconnect from the client. */ - disconnect: function TS_disconnect() { + disconnect: function() { if (!this.activeThread) { return; } dumpn("ThreadState is disconnecting..."); this.activeThread.removeListener("paused", this._update); this.activeThread.removeListener("resumed", this._update); }, /** * Handles any initialization on a tab navigation event issued by the client. */ - _handleTabNavigation: function TS__handleTabNavigation() { + _handleTabNavigation: function() { if (!this.activeThread) { return; } dumpn("Handling tab navigation in the ThreadState"); this._update(); }, /** * Update the UI after a thread state change. */ - _update: function TS__update(aEvent) { + _update: function(aEvent) { DebuggerView.Toolbar.toggleResumeButtonState(this.activeThread.state); if (DebuggerController._target && (aEvent == "paused" || aEvent == "resumed")) { DebuggerController._target.emit("thread-" + aEvent); } } }; @@ -429,56 +427,56 @@ StackFrames.prototype = { currentWatchExpressions: null, currentBreakpointLocation: null, currentEvaluation: null, currentException: null, /** * Connect to the current thread client. */ - connect: function SF_connect() { + connect: function() { dumpn("StackFrames is connecting..."); this.activeThread.addListener("paused", this._onPaused); this.activeThread.addListener("resumed", this._onResumed); this.activeThread.addListener("framesadded", this._onFrames); this.activeThread.addListener("framescleared", this._onFramesCleared); this._handleTabNavigation(); }, /** * Disconnect from the client. */ - disconnect: function SF_disconnect() { + disconnect: function() { if (!this.activeThread) { return; } dumpn("StackFrames is disconnecting..."); this.activeThread.removeListener("paused", this._onPaused); this.activeThread.removeListener("resumed", this._onResumed); this.activeThread.removeListener("framesadded", this._onFrames); this.activeThread.removeListener("framescleared", this._onFramesCleared); }, /** * Handles any initialization on a tab navigation event issued by the client. */ - _handleTabNavigation: function SF__handleTabNavigation() { + _handleTabNavigation: function() { dumpn("Handling tab navigation in the StackFrames"); // Nothing to do here yet. }, /** * Handler for the thread client's paused notification. * * @param string aEvent * The name of the notification ("paused" in this case). * @param object aPacket * The response packet. */ - _onPaused: function SF__onPaused(aEvent, aPacket) { + _onPaused: function(aEvent, aPacket) { switch (aPacket.why.type) { // If paused by a breakpoint, store the breakpoint location. case "breakpoint": this.currentBreakpointLocation = aPacket.frame.where; break; // If paused by a client evaluation, store the evaluated value. case "clientEvaluated": this.currentEvaluation = aPacket.why.frameFinished; @@ -491,29 +489,29 @@ StackFrames.prototype = { this.activeThread.fillFrames(CALL_STACK_PAGE_SIZE); DebuggerView.editor.focus(); }, /** * Handler for the thread client's resumed notification. */ - _onResumed: function SF__onResumed() { + _onResumed: function() { DebuggerView.editor.setDebugLocation(-1); // Prepare the watch expression evaluation string for the next pause. if (!this._isWatchExpressionsEvaluation) { this.currentWatchExpressions = this.syncedWatchExpressions; } }, /** * Handler for the thread client's framesadded notification. */ - _onFrames: function SF__onFrames() { + _onFrames: function() { // Ignore useless notifications. if (!this.activeThread.cachedFrames.length) { return; } // Conditional breakpoints are { breakpoint, expression } tuples. The // boolean evaluation of the expression decides if the active thread // automatically resumes execution or not. @@ -586,33 +584,33 @@ StackFrames.prototype = { if (this.activeThread.moreFrames) { DebuggerView.StackFrames.dirty = true; } }, /** * Handler for the thread client's framescleared notification. */ - _onFramesCleared: function SF__onFramesCleared() { + _onFramesCleared: function() { this.currentFrame = null; this.currentWatchExpressions = null; this.currentBreakpointLocation = null; this.currentEvaluation = null; this.currentException = null; // After each frame step (in, over, out), framescleared is fired, which // forces the UI to be emptied and rebuilt on framesadded. Most of the times // this is not necessary, and will result in a brief redraw flicker. // To avoid it, invalidate the UI only after a short time if necessary. window.setTimeout(this._afterFramesCleared, FRAME_STEP_CLEAR_DELAY); }, /** * Called soon after the thread client's framescleared notification. */ - _afterFramesCleared: function SF__afterFramesCleared() { + _afterFramesCleared: function() { // Ignore useless notifications. if (this.activeThread.cachedFrames.length) { return; } DebuggerView.StackFrames.empty(); DebuggerView.Sources.unhighlightBreakpoint(); DebuggerView.WatchExpressions.toggleContents(true); DebuggerView.Variables.empty(0); @@ -621,17 +619,17 @@ StackFrames.prototype = { /** * Marks the stack frame at the specified depth as selected and updates the * properties view with the stack frame's data. * * @param number aDepth * The depth of the frame in the stack. */ - selectFrame: function SF_selectFrame(aDepth) { + selectFrame: function(aDepth) { let frame = this.activeThread.cachedFrames[this.currentFrame = aDepth]; if (!frame) { return; } let { environment, watchExpressionsEvaluation } = frame; let { url, line } = frame.where; // Check if the frame does not represent the evaluation of debuggee code. @@ -699,17 +697,17 @@ StackFrames.prototype = { * Adds an 'onexpand' callback for a scope, lazily handling * the addition of new variables. * * @param Scope aScope * The scope where the variables will be placed into. * @param object aEnv * The scope's environment. */ - _addScopeExpander: function SF__addScopeExpander(aScope, aEnv) { + _addScopeExpander: function(aScope, aEnv) { aScope._sourceEnvironment = aEnv; // It's a good idea to be prepared in case of an expansion. aScope.addEventListener("mouseover", this._fetchScopeVariables, false); // Make sure that variables are always available on expansion. aScope.onexpand = this._fetchScopeVariables; }, @@ -717,17 +715,17 @@ StackFrames.prototype = { * Adds an 'onexpand' callback for a variable, lazily handling * the addition of new properties. * * @param Variable aVar * The variable where the properties will be placed into. * @param any aGrip * The grip of the variable. */ - _addVarExpander: function SF__addVarExpander(aVar, aGrip) { + _addVarExpander: function(aVar, aGrip) { // No need for expansion for primitive values. if (VariablesView.isPrimitive({ value: aGrip })) { return; } aVar._sourceGrip = aGrip; // Some variables are likely to contain a very large number of properties. // It's a good idea to be prepared in case of an expansion. @@ -741,25 +739,25 @@ StackFrames.prototype = { /** * Adds the watch expressions evaluation results to a scope in the view. * * @param Scope aScope * The scope where the watch expressions will be placed into. * @param object aExp * The grip of the evaluation results. */ - _fetchWatchExpressions: function SF__fetchWatchExpressions(aScope, aExp) { + _fetchWatchExpressions: function(aScope, aExp) { // Fetch the expressions only once. if (aScope._fetched) { return; } aScope._fetched = true; // Add nodes for every watch expression in scope. - this.activeThread.pauseGrip(aExp).getPrototypeAndProperties(function(aResponse) { + this.activeThread.pauseGrip(aExp).getPrototypeAndProperties((aResponse) => { let ownProperties = aResponse.ownProperties; let totalExpressions = DebuggerView.WatchExpressions.itemCount; for (let i = 0; i < totalExpressions; i++) { let name = DebuggerView.WatchExpressions.getExpression(i); let expVal = ownProperties[i].value; let expRef = aScope.addVar(name, ownProperties[i]); this._addVarExpander(expRef, expVal); @@ -769,47 +767,47 @@ StackFrames.prototype = { expRef.delete = null; expRef.descriptorTooltip = true; expRef.separatorStr = L10N.getStr("variablesSeparatorLabel"); } // Signal that watch expressions have been fetched. window.dispatchEvent(document, "Debugger:FetchedWatchExpressions"); DebuggerView.Variables.commitHierarchy(); - }.bind(this)); + }); }, /** * Adds variables to a scope in the view. Triggered when a scope is * expanded or is hovered. It does not expand the scope. * * @param Scope aScope * The scope where the variables will be placed into. */ - _fetchScopeVariables: function SF__fetchScopeVariables(aScope) { + _fetchScopeVariables: function(aScope) { // Fetch the variables only once. if (aScope._fetched) { return; } aScope._fetched = true; let env = aScope._sourceEnvironment; switch (env.type) { case "with": case "object": // Add nodes for every variable in scope. - this.activeThread.pauseGrip(env.object).getPrototypeAndProperties(function(aResponse) { + this.activeThread.pauseGrip(env.object).getPrototypeAndProperties((aResponse) => { let { ownProperties, safeGetterValues } = aResponse; this._mergeSafeGetterValues(ownProperties, safeGetterValues); this._insertScopeVariables(ownProperties, aScope); // Signal that variables have been fetched. window.dispatchEvent(document, "Debugger:FetchedVariables"); DebuggerView.Variables.commitHierarchy(); - }.bind(this)); + }); break; case "block": case "function": // Add nodes for every argument and every other variable in scope. this._insertScopeArguments(env.bindings.arguments, aScope); this._insertScopeVariables(env.bindings.variables, aScope); // No need to signal that variables have been fetched, since @@ -825,17 +823,17 @@ StackFrames.prototype = { /** * Add nodes for special frame references in the innermost scope. * * @param Scope aScope * The scope where the references will be placed into. * @param object aFrame * The frame to get some references from. */ - _insertScopeFrameReferences: function SF__insertScopeFrameReferences(aScope, aFrame) { + _insertScopeFrameReferences: function(aScope, aFrame) { // Add any thrown exception. if (this.currentException) { let excRef = aScope.addVar("<exception>", { value: this.currentException }); this._addVarExpander(excRef, this.currentException); } // Add "this". if (aFrame.this) { let thisRef = aScope.addVar("this", { value: aFrame.this }); @@ -846,17 +844,17 @@ StackFrames.prototype = { /** * Add nodes for every argument in scope. * * @param object aArguments * The map of names to arguments, as specified in the protocol. * @param Scope aScope * The scope where the nodes will be placed into. */ - _insertScopeArguments: function SF__insertScopeArguments(aArguments, aScope) { + _insertScopeArguments: function(aArguments, aScope) { if (!aArguments) { return; } for (let argument of aArguments) { let name = Object.getOwnPropertyNames(argument)[0]; let argRef = aScope.addVar(name, argument[name]); let argVal = argument[name].value; this._addVarExpander(argRef, argVal); @@ -866,17 +864,17 @@ StackFrames.prototype = { /** * Add nodes for every variable in scope. * * @param object aVariables * The map of names to variables, as specified in the protocol. * @param Scope aScope * The scope where the nodes will be placed into. */ - _insertScopeVariables: function SF__insertScopeVariables(aVariables, aScope) { + _insertScopeVariables: function(aVariables, aScope) { if (!aVariables) { return; } let variableNames = Object.keys(aVariables); // Sort all of the variables before adding them, if preferred. if (Prefs.variablesSortingEnabled) { variableNames.sort(); @@ -891,25 +889,25 @@ StackFrames.prototype = { /** * Adds properties to a variable in the view. Triggered when a variable is * expanded or certain variables are hovered. It does not expand the variable. * * @param Variable aVar * The variable where the properties will be placed into. */ - _fetchVarProperties: function SF__fetchVarProperties(aVar) { + _fetchVarProperties: function(aVar) { // Fetch the properties only once. if (aVar._fetched) { return; } aVar._fetched = true; let grip = aVar._sourceGrip; - this.activeThread.pauseGrip(grip).getPrototypeAndProperties(function(aResponse) { + this.activeThread.pauseGrip(grip).getPrototypeAndProperties((aResponse) => { let { ownProperties, prototype, safeGetterValues } = aResponse; let sortable = VariablesView.NON_SORTABLE_CLASSES.indexOf(grip.class) == -1; this._mergeSafeGetterValues(ownProperties, safeGetterValues); // Add all the variable properties. if (ownProperties) { aVar.addProperties(ownProperties, { @@ -928,73 +926,71 @@ StackFrames.prototype = { } // Mark the variable as having retrieved all its properties. aVar._retrieved = true; // Signal that properties have been fetched. window.dispatchEvent(document, "Debugger:FetchedProperties"); DebuggerView.Variables.commitHierarchy(); - }.bind(this)); + }); }, /** * Merge the safe getter values descriptors into the "own properties" object * that comes from a "prototypeAndProperties" response packet. This is needed * for Variables View. * * @private * @param object aOwnProperties * The |ownProperties| object that will get the new safe getter values. * @param object aSafeGetterValues * The |safeGetterValues| object. */ - _mergeSafeGetterValues: - function SF__mergeSafeGetterValues(aOwnProperties, aSafeGetterValues) { + _mergeSafeGetterValues: function(aOwnProperties, aSafeGetterValues) { // Merge the safe getter values into one object such that we can use it // in VariablesView. for (let name of Object.keys(aSafeGetterValues)) { if (name in aOwnProperties) { aOwnProperties[name].getterValue = aSafeGetterValues[name].getterValue; - aOwnProperties[name].getterPrototypeLevel = aSafeGetterValues[name] - .getterPrototypeLevel; - } - else { + aOwnProperties[name].getterPrototypeLevel = + aSafeGetterValues[name].getterPrototypeLevel; + } else { aOwnProperties[name] = aSafeGetterValues[name]; } } }, /** * Adds the specified stack frame to the list. * * @param object aFrame * The new frame to add. */ - _addFrame: function SF__addFrame(aFrame) { + _addFrame: function(aFrame) { let depth = aFrame.depth; let { url, line } = aFrame.where; let frameLocation = NetworkHelper.convertToUnicode(unescape(url)); let frameTitle = StackFrameUtils.getFrameTitle(aFrame); DebuggerView.StackFrames.addFrame(frameTitle, frameLocation, line, depth); }, /** * Loads more stack frames from the debugger server cache. */ - addMoreFrames: function SF_addMoreFrames() { + addMoreFrames: function() { this.activeThread.fillFrames( this.activeThread.cachedFrames.length + CALL_STACK_PAGE_SIZE); }, /** * Updates a list of watch expressions to evaluate on each pause. */ - syncWatchExpressions: function SF_syncWatchExpressions() { + syncWatchExpressions: function() { let list = DebuggerView.WatchExpressions.getExpressions(); // Sanity check all watch expressions before syncing them. To avoid // having the whole watch expressions array throw because of a single // faulty expression, simply convert it to a string describing the error. // There's no other information necessary to be offered in such cases. let sanitizedExpressions = list.map(function(str) { // Reflect.parse throws when it encounters a syntax error. @@ -1035,17 +1031,17 @@ StackFrames.prototype = { * Evaluate an expression in the context of the selected frame. This is used * for modifying the value of variables or properties in scope. * * @param string aExpression * The expression to evaluate. * @param number aFrame [optional] * The frame depth used for evaluation. */ - evaluate: function SF_evaluate(aExpression, aFrame = this.currentFrame || 0) { + evaluate: function(aExpression, aFrame = this.currentFrame || 0) { let frame = this.activeThread.cachedFrames[aFrame]; this.activeThread.eval(frame.actor, aExpression); } }; /** * Keeps the source script list up-to-date, using the thread client's * source script cache. @@ -1063,63 +1059,63 @@ function SourceScripts() { SourceScripts.prototype = { get activeThread() DebuggerController.activeThread, get debuggerClient() DebuggerController.client, _newSourceTimeout: null, /** * Connect to the current thread client. */ - connect: function SS_connect() { + connect: function() { dumpn("SourceScripts is connecting..."); this.debuggerClient.addListener("newGlobal", this._onNewGlobal); this.debuggerClient.addListener("newSource", this._onNewSource); this._handleTabNavigation(); }, /** * Disconnect from the client. */ - disconnect: function SS_disconnect() { + disconnect: function() { if (!this.activeThread) { return; } dumpn("SourceScripts is disconnecting..."); window.clearTimeout(this._newSourceTimeout); this.debuggerClient.removeListener("newGlobal", this._onNewGlobal); this.debuggerClient.removeListener("newSource", this._onNewSource); }, /** * Handles any initialization on a tab navigation event issued by the client. */ - _handleTabNavigation: function SS__handleTabNavigation() { + _handleTabNavigation: function() { if (!this.activeThread) { return; } dumpn("Handling tab navigation in the SourceScripts"); window.clearTimeout(this._newSourceTimeout); // Retrieve the list of script sources known to the server from before // the client was ready to handle "newSource" notifications. this.activeThread.getSources(this._onSourcesAdded); }, /** * Handler for the debugger client's unsolicited newGlobal notification. */ - _onNewGlobal: function SS__onNewGlobal(aNotification, aPacket) { + _onNewGlobal: function(aNotification, aPacket) { // TODO: bug 806775, update the globals list using aPacket.hostAnnotations // from bug 801084. }, /** * Handler for the debugger client's unsolicited newSource notification. */ - _onNewSource: function SS__onNewSource(aNotification, aPacket) { + _onNewSource: function(aNotification, aPacket) { // Ignore bogus scripts, e.g. generated from 'clientEvaluate' packets. if (NEW_SOURCE_IGNORED_URLS.indexOf(aPacket.source.url) != -1) { return; } // Add the source in the debugger view sources container. DebuggerView.Sources.addSource(aPacket.source, { staged: false }); @@ -1149,17 +1145,17 @@ SourceScripts.prototype = { // Signal that a new script has been added. window.dispatchEvent(document, "Debugger:AfterNewSource"); }, /** * Callback for the debugger's active thread getSources() method. */ - _onSourcesAdded: function SS__onSourcesAdded(aResponse) { + _onSourcesAdded: function(aResponse) { if (aResponse.error) { Cu.reportError(new Error("Error getting sources: " + aResponse.message)); return; } // Add all the sources in the debugger view sources container. for (let source of aResponse.sources) { // Ignore bogus scripts, e.g. generated from 'clientEvaluate' packets. @@ -1198,17 +1194,17 @@ SourceScripts.prototype = { * * @param object aSource * The source object coming from the active thread. * @param function aCallback * Function called after the source text has been loaded. * @param function aTimeout * Function called when the source text takes too long to fetch. */ - getText: function SS_getText(aSource, aCallback, aTimeout) { + getText: function(aSource, aCallback, aTimeout) { // If already loaded, return the source text immediately. if (aSource.loaded) { aCallback(aSource); return; } // If the source text takes too long to fetch, invoke a timeout to // avoid blocking any operations. @@ -1235,43 +1231,43 @@ SourceScripts.prototype = { }, /** * Gets all the fetched sources. * * @return array * An array containing [url, text] entries for the fetched sources. */ - getCache: function SS_getCache() { + getCache: function() { let sources = []; for (let source of this._cache) { sources.push(source); } return sources.sort(([first], [second]) => first > second); }, /** * Clears all the fetched sources from cache. */ - clearCache: function SS_clearCache() { + clearCache: function() { this._cache.clear(); }, /** * Starts fetching all the sources, silently. * * @param array aUrls * The urls for the sources to fetch. * @param object aCallbacks [optional] * An object containing the callback functions to invoke: * - onFetch: optional, called after each source is fetched * - onTimeout: optional, called when a source takes too long to fetch * - onFinished: called when all the sources are fetched */ - fetchSources: function SS_fetchSources(aUrls, aCallbacks = {}) { + fetchSources: function(aUrls, aCallbacks = {}) { this._fetchQueue = new Set(); this._fetchCallbacks = aCallbacks; // Add each new source which needs to be fetched in a queue. for (let url of aUrls) { if (!this._cache.has(url)) { this._fetchQueue.add(url); } @@ -1292,17 +1288,17 @@ SourceScripts.prototype = { }, /** * Called when a source has been fetched via fetchSources(). * * @param object aSource * The source object coming from the active thread. */ - _onFetch: function SS__onFetch(aSource) { + _onFetch: function(aSource) { // Remember the source in a cache so we don't have to fetch it again. this._cache.set(aSource.url, aSource.text); // Fetch completed before timeout, remove the source from the fetch queue. this._fetchQueue.delete(aSource.url); // If this fetch was eventually completed at some point after a timeout, // don't call any subsequent event listeners. @@ -1322,17 +1318,17 @@ SourceScripts.prototype = { }, /** * Called when a source's text takes too long to fetch via fetchSources(). * * @param object aSource * The source object coming from the active thread. */ - _onTimeout: function SS__onTimeout(aSource) { + _onTimeout: function(aSource) { // Remove the source from the fetch queue. this._fetchQueue.delete(aSource.url); // Invoke the source timeout callback if provided via fetchSources(); if (this._fetchCallbacks.onTimeout) { this._fetchCallbacks.onTimeout(aSource); } @@ -1340,17 +1336,17 @@ SourceScripts.prototype = { if (this._fetchQueue.size == 0) { this._onFinished(); } }, /** * Called when all the sources have been fetched. */ - _onFinished: function SS__onFinished() { + _onFinished: function() { // Invoke the finish callback if provided via fetchSources(); if (this._fetchCallbacks.onFinished) { this._fetchCallbacks.onFinished(); } }, _cache: null, _fetchQueue: null, @@ -1393,106 +1389,106 @@ Breakpoints.prototype = { * This implementation relies on the fact that the source editor fires the * BREAKPOINT_CHANGE events synchronously. */ _skipEditorBreakpointCallbacks: false, /** * Adds the source editor breakpoint handlers. */ - initialize: function BP_initialize() { + initialize: function() { this.editor.addEventListener( SourceEditor.EVENTS.BREAKPOINT_CHANGE, this._onEditorBreakpointChange); }, /** * Removes the source editor breakpoint handlers & all the added breakpoints. */ - destroy: function BP_destroy() { + destroy: function() { this.editor.removeEventListener( SourceEditor.EVENTS.BREAKPOINT_CHANGE, this._onEditorBreakpointChange); for each (let breakpointClient in this.store) { this.removeBreakpoint(breakpointClient); } }, /** * Event handler for breakpoint changes that happen in the editor. This * function syncs the breakpoints in the editor to those in the debugger. * * @param object aEvent * The SourceEditor.EVENTS.BREAKPOINT_CHANGE event object. */ - _onEditorBreakpointChange: function BP__onEditorBreakpointChange(aEvent) { + _onEditorBreakpointChange: function(aEvent) { if (this._skipEditorBreakpointCallbacks) { return; } this._skipEditorBreakpointCallbacks = true; aEvent.added.forEach(this._onEditorBreakpointAdd, this); aEvent.removed.forEach(this._onEditorBreakpointRemove, this); this._skipEditorBreakpointCallbacks = false; }, /** * Event handler for new breakpoints that come from the editor. * * @param object aEditorBreakpoint * The breakpoint object coming from the editor. */ - _onEditorBreakpointAdd: function BP__onEditorBreakpointAdd(aEditorBreakpoint) { + _onEditorBreakpointAdd: function(aEditorBreakpoint) { let url = DebuggerView.Sources.selectedValue; let line = aEditorBreakpoint.line + 1; - this.addBreakpoint({ url: url, line: line }, function(aBreakpointClient) { + this.addBreakpoint({ url: url, line: line }, (aBreakpointClient) => { // If the breakpoint client has an "actualLocation" attached, then // the original requested placement for the breakpoint wasn't accepted. // In this case, we need to update the editor with the new location. if (aBreakpointClient.actualLocation) { this.editor.removeBreakpoint(line - 1); this.editor.addBreakpoint(aBreakpointClient.actualLocation.line - 1); } - }.bind(this)); + }); }, /** * Event handler for breakpoints that are removed from the editor. * * @param object aEditorBreakpoint * The breakpoint object that was removed from the editor. */ - _onEditorBreakpointRemove: function BP__onEditorBreakpointRemove(aEditorBreakpoint) { + _onEditorBreakpointRemove: function(aEditorBreakpoint) { let url = DebuggerView.Sources.selectedValue; let line = aEditorBreakpoint.line + 1; this.removeBreakpoint(this.getBreakpoint(url, line)); }, /** * Update the breakpoints in the editor view. This function takes the list of * breakpoints in the debugger and adds them back into the editor view. * This is invoked when the selected script is changed. */ - updateEditorBreakpoints: function BP_updateEditorBreakpoints() { + updateEditorBreakpoints: function() { for each (let breakpointClient in this.store) { if (DebuggerView.Sources.selectedValue == breakpointClient.location.url) { this._showBreakpoint(breakpointClient, { noPaneUpdate: true, noPaneHighlight: true }); } } }, /** * Update the breakpoints in the pane view. This function takes the list of * breakpoints in the debugger and adds them back into the breakpoints pane. * This is invoked when scripts are added. */ - updatePaneBreakpoints: function BP_updatePaneBreakpoints() { + updatePaneBreakpoints: function() { for each (let breakpointClient in this.store) { if (DebuggerView.Sources.containsValue(breakpointClient.location.url)) { this._showBreakpoint(breakpointClient, { noEditorUpdate: true, noPaneHighlight: true }); } } @@ -1514,27 +1510,26 @@ Breakpoints.prototype = { * @param object aFlags [optional] * An object containing some of the following boolean properties: * - conditionalExpression: tells this breakpoint's conditional expression * - openPopup: tells if the expression popup should be shown * - noEditorUpdate: tells if you want to skip editor updates * - noPaneUpdate: tells if you want to skip breakpoint pane updates * - noPaneHighlight: tells if you don't want to highlight the breakpoint */ - addBreakpoint: - function BP_addBreakpoint(aLocation, aCallback, aFlags = {}) { + addBreakpoint: function(aLocation, aCallback, aFlags = {}) { let breakpointClient = this.getBreakpoint(aLocation.url, aLocation.line); // If the breakpoint was already added, callback immediately. if (breakpointClient) { aCallback && aCallback(breakpointClient); return; } - this.activeThread.setBreakpoint(aLocation, function(aResponse, aBreakpointClient) { + this.activeThread.setBreakpoint(aLocation, (aResponse, aBreakpointClient) => { let { url, line } = aResponse.actualLocation || aLocation; // If the response contains a breakpoint that exists in the cache, prevent // it from being shown in the source editor at an incorrect position. if (this.getBreakpoint(url, line)) { this._hideBreakpoint(aBreakpointClient); return; } @@ -1564,62 +1559,61 @@ Breakpoints.prototype = { // the sources pane without requiring fetching the source. aBreakpointClient.lineText = DebuggerView.getEditorLine(line - 1).trim(); // Show the breakpoint in the editor and breakpoints pane. this._showBreakpoint(aBreakpointClient, aFlags); // We're done here. aCallback && aCallback(aBreakpointClient, aResponse.error); - }.bind(this)); + }); }, /** * Remove a breakpoint. * * @param object aBreakpointClient * The BreakpointActor client object to remove. * @param function aCallback [optional] * Optional function to invoke once the breakpoint is removed. The * callback is invoked with one argument * - aBreakpointClient: the breakpoint location (url and line) * @param object aFlags [optional] * @see DebuggerController.Breakpoints.addBreakpoint */ - removeBreakpoint: - function BP_removeBreakpoint(aBreakpointClient, aCallback, aFlags = {}) { + removeBreakpoint: function(aBreakpointClient, aCallback, aFlags = {}) { let breakpointActor = (aBreakpointClient || {}).actor; // If the breakpoint was already removed, callback immediately. if (!this.store[breakpointActor]) { aCallback && aCallback(aBreakpointClient.location); return; } - aBreakpointClient.remove(function() { + aBreakpointClient.remove(() => { // Delete the breakpoint client from the store. delete this.store[breakpointActor]; // Hide the breakpoint from the editor and breakpoints pane. this._hideBreakpoint(aBreakpointClient, aFlags); // We're done here. aCallback && aCallback(aBreakpointClient.location); - }.bind(this)); + }); }, /** * Update the editor and breakpoints pane to show a specified breakpoint. * * @param object aBreakpointClient * The BreakpointActor client object to show. * @param object aFlags [optional] * @see DebuggerController.Breakpoints.addBreakpoint */ - _showBreakpoint: function BP__showBreakpoint(aBreakpointClient, aFlags = {}) { + _showBreakpoint: function(aBreakpointClient, aFlags = {}) { let currentSourceUrl = DebuggerView.Sources.selectedValue; let { url, line } = aBreakpointClient.location; // Update the editor if required. if (!aFlags.noEditorUpdate) { if (url == currentSourceUrl) { this._skipEditorBreakpointCallbacks = true; this.editor.addBreakpoint(line - 1); @@ -1645,17 +1639,17 @@ Breakpoints.prototype = { /** * Update the editor and breakpoints pane to hide a specified breakpoint. * * @param object aBreakpointClient * The BreakpointActor client object to hide. * @param object aFlags [optional] * @see DebuggerController.Breakpoints.addBreakpoint */ - _hideBreakpoint: function BP__hideBreakpoint(aBreakpointClient, aFlags = {}) { + _hideBreakpoint: function(aBreakpointClient, aFlags = {}) { let currentSourceUrl = DebuggerView.Sources.selectedValue; let { url, line } = aBreakpointClient.location; // Update the editor if required. if (!aFlags.noEditorUpdate) { if (url == currentSourceUrl) { this._skipEditorBreakpointCallbacks = true; this.editor.removeBreakpoint(line - 1); @@ -1673,17 +1667,17 @@ Breakpoints.prototype = { * * @param string aUrl * The URL of where the breakpoint is. * @param number aLine * The line number where the breakpoint is. * @return object * The BreakpointActor object. */ - getBreakpoint: function BP_getBreakpoint(aUrl, aLine) { + getBreakpoint: function(aUrl, aLine) { for each (let breakpointClient in this.store) { if (breakpointClient.location.url == aUrl && breakpointClient.location.line == aLine) { return breakpointClient; } } return null; }
--- a/browser/devtools/debugger/debugger-panes.js +++ b/browser/devtools/debugger/debugger-panes.js @@ -28,17 +28,17 @@ function SourcesView() { this._onConditionalTextboxInput = this._onConditionalTextboxInput.bind(this); this._onConditionalTextboxKeyPress = this._onConditionalTextboxKeyPress.bind(this); } create({ constructor: SourcesView, proto: MenuContainer.prototype }, { /** * Initialization function, called when the debugger is started. */ - initialize: function DVS_initialize() { + initialize: function() { dumpn("Initializing the SourcesView"); this.node = new SideMenuWidget(document.getElementById("sources")); this.emptyText = L10N.getStr("noSourcesText"); this.unavailableText = L10N.getStr("noMatchingSourcesText"); this._commandset = document.getElementById("debuggerCommands"); this._popupset = document.getElementById("debuggerPopupset"); @@ -59,17 +59,17 @@ create({ constructor: SourcesView, proto // Show an empty label by default. this.empty(); }, /** * Destruction function, called when the debugger is closed. */ - destroy: function DVS_destroy() { + destroy: function() { dumpn("Destroying the SourcesView"); window.removeEventListener("Debugger:EditorLoaded", this._onEditorLoad, false); window.removeEventListener("Debugger:EditorUnloaded", this._onEditorUnload, false); this.node.removeEventListener("mousedown", this._onSourceMouseDown, false); this.node.removeEventListener("select", this._onSourceSelect, false); this.node.removeEventListener("click", this._onSourceClick, false); this._cbPanel.removeEventListener("popupshowing", this._onConditionalPopupShowing, false); @@ -97,17 +97,17 @@ create({ constructor: SourcesView, proto * Adds a source to this sources container. * * @param object aSource * The source object coming from the active thread. * @param object aOptions [optional] * Additional options for adding the source. Supported options: * - forced: force the source to be immediately added */ - addSource: function DVS_addSource(aSource, aOptions = {}) { + addSource: function(aSource, aOptions = {}) { let url = aSource.url; let label = SourceUtils.getSourceLabel(url.split(" -> ").pop()); let group = SourceUtils.getSourceGroup(url.split(" -> ").pop()); // Append a source item to this container. let sourceItem = this.push([label, url, group], { staged: aOptions.staged, /* stage the item to be appended later? */ attachment: { @@ -127,17 +127,17 @@ create({ constructor: SourcesView, proto * The breakpoint's line number to be displayed. * - string lineText * The breakpoint's line text to be displayed. * - string actor * A breakpoint identifier specified by the debugger controller. * - boolean openPopupFlag [optional] * A flag specifying if the expression popup should be shown. */ - addBreakpoint: function DVS_addBreakpoint(aOptions) { + addBreakpoint: function(aOptions) { let { sourceLocation: url, lineNumber: line } = aOptions; // Make sure we're not duplicating anything. If a breakpoint at the // specified source location and line number already exists, just enable it. if (this.getBreakpoint(url, line)) { this.enableBreakpoint(url, line, { id: aOptions.actor }); return; } @@ -175,17 +175,17 @@ create({ constructor: SourcesView, proto /** * Removes a breakpoint from this sources container. * * @param string aSourceLocation * The breakpoint source location. * @param number aLineNumber * The breakpoint line number. */ - removeBreakpoint: function DVS_removeBreakpoint(aSourceLocation, aLineNumber) { + removeBreakpoint: function(aSourceLocation, aLineNumber) { // When a parent source item is removed, all the child breakpoint items are // also automagically removed. let sourceItem = this.getItemByValue(aSourceLocation); if (!sourceItem) { return; } let breakpointItem = this.getBreakpoint(aSourceLocation, aLineNumber); if (!breakpointItem) { @@ -204,17 +204,17 @@ create({ constructor: SourcesView, proto * * @param string aSourceLocation * The breakpoint source location. * @param number aLineNumber * The breakpoint line number. * @return MenuItem * The corresponding breakpoint item if found, null otherwise. */ - getBreakpoint: function DVS_getBreakpoint(aSourceLocation, aLineNumber) { + getBreakpoint: function(aSourceLocation, aLineNumber) { let breakpointKey = this._getBreakpointKey(aSourceLocation, aLineNumber); return this._breakpointsCache.get(breakpointKey); }, /** * Enables a breakpoint. * * @param string aSourceLocation @@ -226,18 +226,17 @@ create({ constructor: SourcesView, proto * - silent: pass true to not update the checkbox checked state; * this is usually necessary when the checked state will * be updated automatically (e.g: on a checkbox click). * - callback: function to invoke once the breakpoint is enabled * - id: a new id to be applied to the corresponding element node * @return boolean * True if breakpoint existed and was enabled, false otherwise. */ - enableBreakpoint: - function DVS_enableBreakpoint(aSourceLocation, aLineNumber, aOptions = {}) { + enableBreakpoint: function(aSourceLocation, aLineNumber, aOptions = {}) { let breakpointItem = this.getBreakpoint(aSourceLocation, aLineNumber); if (!breakpointItem) { return false; } // Set a new id to the corresponding breakpoint element if required. if (aOptions.id) { breakpointItem.attachment.view.container.id = "breakpoint-" + aOptions.id; @@ -272,18 +271,17 @@ create({ constructor: SourcesView, proto * Additional options or flags supported by this operation: * - silent: pass true to not update the checkbox checked state; * this is usually necessary when the checked state will * be updated automatically (e.g: on a checkbox click). * - callback: function to invoke once the breakpoint is disabled * @return boolean * True if breakpoint existed and was disabled, false otherwise. */ - disableBreakpoint: - function DVS_disableBreakpoint(aSourceLocation, aLineNumber, aOptions = {}) { + disableBreakpoint: function(aSourceLocation, aLineNumber, aOptions = {}) { let breakpointItem = this.getBreakpoint(aSourceLocation, aLineNumber); if (!breakpointItem) { return false; } // Update the checkbox state if necessary. if (!aOptions.silent) { breakpointItem.attachment.view.checkbox.removeAttribute("checked"); @@ -310,18 +308,17 @@ create({ constructor: SourcesView, proto * The breakpoint source location. * @param number aLineNumber * The breakpoint line number. * @param object aFlags [optional] * An object containing some of the following boolean properties: * - updateEditor: true if editor updates should be allowed * - openPopup: true if the expression popup should be shown */ - highlightBreakpoint: - function DVS_highlightBreakpoint(aSourceLocation, aLineNumber, aFlags = {}) { + highlightBreakpoint: function(aSourceLocation, aLineNumber, aFlags = {}) { let breakpointItem = this.getBreakpoint(aSourceLocation, aLineNumber); if (!breakpointItem) { return; } // Breakpoint is now selected. this._selectBreakpoint(breakpointItem); @@ -337,17 +334,17 @@ create({ constructor: SourcesView, proto } else { this._hideConditionalPopup(); } }, /** * Unhighlights the current breakpoint in this sources container. */ - unhighlightBreakpoint: function DVS_unhighlightBreakpoint() { + unhighlightBreakpoint: function() { this._unselectBreakpoint(); this._hideConditionalPopup(); }, /** * Gets the currently selected breakpoint item. * @return object */ @@ -367,42 +364,42 @@ create({ constructor: SourcesView, proto }, /** * Marks a breakpoint as selected in this sources container. * * @param MenuItem aItem * The breakpoint item to select. */ - _selectBreakpoint: function DVS__selectBreakpoint(aItem) { + _selectBreakpoint: function(aItem) { if (this._selectedBreakpoint == aItem) { return; } this._unselectBreakpoint(); this._selectedBreakpoint = aItem; this._selectedBreakpoint.markSelected(); // Ensure the currently selected breakpoint is visible. this.node.ensureElementIsVisible(aItem.target); }, /** * Marks the current breakpoint as unselected in this sources container. */ - _unselectBreakpoint: function DVS__unselectBreakpoint() { + _unselectBreakpoint: function() { if (this._selectedBreakpoint) { this._selectedBreakpoint.markDeselected(); this._selectedBreakpoint = null; } }, /** * Opens a conditional breakpoint's expression input popup. */ - _openConditionalPopup: function DVS__openConditionalPopup() { + _openConditionalPopup: function() { let selectedBreakpoint = this.selectedBreakpoint; let selectedClient = this.selectedClient; if (selectedClient.conditionalExpression === undefined) { this._cbTextbox.value = selectedClient.conditionalExpression = ""; } else { this._cbTextbox.value = selectedClient.conditionalExpression; } @@ -412,17 +409,17 @@ create({ constructor: SourcesView, proto BREAKPOINT_CONDITIONAL_POPUP_POSITION, BREAKPOINT_CONDITIONAL_POPUP_OFFSET_X, BREAKPOINT_CONDITIONAL_POPUP_OFFSET_Y); }, /** * Hides a conditional breakpoint's expression input popup. */ - _hideConditionalPopup: function DVS__hideConditionalPopup() { + _hideConditionalPopup: function() { this._cbPanel.hidden = true; this._cbPanel.hidePopup(); }, /** * Customization function for creating a breakpoint item's UI. * * @param object aOptions @@ -430,17 +427,17 @@ create({ constructor: SourcesView, proto * - number lineNumber * The line number specified by the debugger controller. * - string lineText * The line text to be displayed. * @return object * An object containing the breakpoint container, checkbox, * line number and line text nodes. */ - _createBreakpointView: function DVS_createBreakpointView(aOptions) { + _createBreakpointView: function(aOptions) { let { lineNumber, lineText } = aOptions; let checkbox = document.createElement("checkbox"); checkbox.setAttribute("checked", "true"); let lineNumberNode = document.createElement("label"); lineNumberNode.className = "plain dbg-breakpoint-line"; lineNumberNode.setAttribute("value", lineNumber); @@ -479,17 +476,17 @@ create({ constructor: SourcesView, proto * * @param aOptions * Additional options or flags supported by this operation: * - string actor * A breakpoint identifier specified by the debugger controller. * @return object * An object containing the breakpoint commandset and menu popup ids. */ - _createContextMenu: function DVS__createContextMenu(aOptions) { + _createContextMenu: function(aOptions) { let commandsetId = "bp-cSet-" + aOptions.actor; let menupopupId = "bp-mPop-" + aOptions.actor; let commandset = document.createElement("commandset"); let menupopup = document.createElement("menupopup"); commandset.id = commandsetId; menupopup.id = menupopupId; @@ -560,190 +557,190 @@ create({ constructor: SourcesView, proto }, /** * Destroys the context menu for a breakpoint. * * @param object aContextMenu * An object containing the breakpoint commandset and menu popup ids. */ - _destroyContextMenu: function DVS__destroyContextMenu(aContextMenu) { + _destroyContextMenu: function(aContextMenu) { dumpn("Destroying context menu: " + aContextMenu.commandsetId + " & " + aContextMenu.menupopupId); let commandset = document.getElementById(aContextMenu.commandsetId); let menupopup = document.getElementById(aContextMenu.menupopupId); commandset.parentNode.removeChild(commandset); menupopup.parentNode.removeChild(menupopup); }, /** * Function called each time a breakpoint item is removed. * * @param MenuItem aItem * The corresponding menu item. */ - _onBreakpointRemoved: function DVS__onBreakpointRemoved(aItem) { + _onBreakpointRemoved: function(aItem) { dumpn("Finalizing breakpoint item: " + aItem); let { sourceLocation: url, lineNumber: line, popup } = aItem.attachment; this._destroyContextMenu(popup); this._breakpointsCache.delete(this._getBreakpointKey(url, line)); }, /** * The load listener for the source editor. */ - _onEditorLoad: function DVS__onEditorLoad({ detail: editor }) { + _onEditorLoad: function({ detail: editor }) { editor.addEventListener("Selection", this._onEditorSelection, false); editor.addEventListener("ContextMenu", this._onEditorContextMenu, false); }, /** * The unload listener for the source editor. */ - _onEditorUnload: function DVS__onEditorUnload({ detail: editor }) { + _onEditorUnload: function({ detail: editor }) { editor.removeEventListener("Selection", this._onEditorSelection, false); editor.removeEventListener("ContextMenu", this._onEditorContextMenu, false); }, /** * The selection listener for the source editor. */ - _onEditorSelection: function DVS__onEditorSelection(e) { + _onEditorSelection: function(e) { let { start, end } = e.newValue; let sourceLocation = this.selectedValue; let lineStart = DebuggerView.editor.getLineAtOffset(start) + 1; let lineEnd = DebuggerView.editor.getLineAtOffset(end) + 1; if (this.getBreakpoint(sourceLocation, lineStart) && lineStart == lineEnd) { this.highlightBreakpoint(sourceLocation, lineStart); } else { this.unhighlightBreakpoint(); } }, /** * The context menu listener for the source editor. */ - _onEditorContextMenu: function DVS__onEditorContextMenu({ x, y }) { + _onEditorContextMenu: function({ x, y }) { let offset = DebuggerView.editor.getOffsetAtLocation(x, y); let line = DebuggerView.editor.getLineAtOffset(offset); this._editorContextMenuLineNumber = line; }, /** * The mouse down listener for the sources container. */ - _onSourceMouseDown: function DVS__onSourceMouseDown(e) { + _onSourceMouseDown: function(e) { let item = this.getItemForElement(e.target); if (item) { // The container is not empty and we clicked on an actual item. this.selectedItem = item; } }, /** * The select listener for the sources container. */ - _onSourceSelect: function DVS__onSourceSelect() { + _onSourceSelect: function() { if (!this.refresh()) { return; } let selectedSource = this.selectedItem.attachment.source; if (DebuggerView.editorSource != selectedSource) { DebuggerView.editorSource = selectedSource; } }, /** * The click listener for the sources container. */ - _onSourceClick: function DVS__onSourceClick() { + _onSourceClick: function() { // Use this container as a filtering target. DebuggerView.Filtering.target = this; }, /** * The click listener for a breakpoint container. */ - _onBreakpointClick: function DVS__onBreakpointClick(e) { + _onBreakpointClick: function(e) { let sourceItem = this.getItemForElement(e.target); let breakpointItem = this.getItemForElement.call(sourceItem, e.target); let { sourceLocation: url, lineNumber: line } = breakpointItem.attachment; let breakpointClient = DebuggerController.Breakpoints.getBreakpoint(url, line); let conditionalExpression = (breakpointClient || {}).conditionalExpression; this.highlightBreakpoint(url, line, { updateEditor: true, openPopup: conditionalExpression !== undefined && e.button == 0 }); }, /** * The click listener for a breakpoint checkbox. */ - _onBreakpointCheckboxClick: function DVS__onBreakpointCheckboxClick(e) { + _onBreakpointCheckboxClick: function(e) { let sourceItem = this.getItemForElement(e.target); let breakpointItem = this.getItemForElement.call(sourceItem, e.target); let { sourceLocation: url, lineNumber: line, disabled } = breakpointItem.attachment; this[disabled ? "enableBreakpoint" : "disableBreakpoint"](url, line, { silent: true }); // Don't update the editor location (propagate into DVS__onBreakpointClick). e.preventDefault(); e.stopPropagation(); }, /** * The popup showing listener for the breakpoints conditional expression panel. */ - _onConditionalPopupShowing: function DVS__onConditionalPopupShowing() { + _onConditionalPopupShowing: function() { this._conditionalPopupVisible = true; }, /** * The popup shown listener for the breakpoints conditional expression panel. */ - _onConditionalPopupShown: function DVS__onConditionalPopupShown() { + _onConditionalPopupShown: function() { this._cbTextbox.focus(); this._cbTextbox.select(); }, /** * The popup hiding listener for the breakpoints conditional expression panel. */ - _onConditionalPopupHiding: function DVS__onConditionalPopupHiding() { + _onConditionalPopupHiding: function() { this._conditionalPopupVisible = false; }, /** * The input listener for the breakpoints conditional expression textbox. */ - _onConditionalTextboxInput: function DVS__onConditionalTextboxInput() { + _onConditionalTextboxInput: function() { this.selectedClient.conditionalExpression = this._cbTextbox.value; }, /** * The keypress listener for the breakpoints conditional expression textbox. */ - _onConditionalTextboxKeyPress: function DVS__onConditionalTextboxKeyPress(e) { + _onConditionalTextboxKeyPress: function(e) { if (e.keyCode == e.DOM_VK_RETURN || e.keyCode == e.DOM_VK_ENTER) { this._hideConditionalPopup(); } }, /** * Called when the add breakpoint key sequence was pressed. */ - _onCmdAddBreakpoint: function BP__onCmdAddBreakpoint() { + _onCmdAddBreakpoint: function() { // If this command was executed via the context menu, add the breakpoint // on the currently hovered line in the source editor. if (this._editorContextMenuLineNumber >= 0) { DebuggerView.editor.setCaretPosition(this._editorContextMenuLineNumber); } // Avoid placing breakpoints incorrectly when using key shortcuts. this._editorContextMenuLineNumber = -1; @@ -761,17 +758,17 @@ create({ constructor: SourcesView, proto let breakpointLocation = { url: url, line: line }; DebuggerController.Breakpoints.addBreakpoint(breakpointLocation); } }, /** * Called when the add conditional breakpoint key sequence was pressed. */ - _onCmdAddConditionalBreakpoint: function BP__onCmdAddConditionalBreakpoint() { + _onCmdAddConditionalBreakpoint: function() { // If this command was executed via the context menu, add the breakpoint // on the currently hovered line in the source editor. if (this._editorContextMenuLineNumber >= 0) { DebuggerView.editor.setCaretPosition(this._editorContextMenuLineNumber); } // Avoid placing breakpoints incorrectly when using key shortcuts. this._editorContextMenuLineNumber = -1; @@ -794,29 +791,29 @@ create({ constructor: SourcesView, proto }, /** * Listener handling the "setConditional" menuitem command. * * @param object aDetails * The breakpoint details (sourceLocation, lineNumber etc.). */ - _onSetConditional: function DVS__onSetConditional(aDetails) { + _onSetConditional: function(aDetails) { let { sourceLocation: url, lineNumber: line, actor } = aDetails; let breakpointItem = this.getBreakpoint(url, line); this.highlightBreakpoint(url, line, { openPopup: true }); }, /** * Listener handling the "enableSelf" menuitem command. * * @param object aDetails * The breakpoint details (sourceLocation, lineNumber etc.). */ - _onEnableSelf: function DVS__onEnableSelf(aDetails) { + _onEnableSelf: function(aDetails) { let { sourceLocation: url, lineNumber: line, actor } = aDetails; if (this.enableBreakpoint(url, line)) { let prefix = "bp-cMenu-"; // "breakpoints context menu" let enableSelfId = prefix + "enableSelf-" + actor + "-menuitem"; let disableSelfId = prefix + "disableSelf-" + actor + "-menuitem"; document.getElementById(enableSelfId).setAttribute("hidden", "true"); document.getElementById(disableSelfId).removeAttribute("hidden"); @@ -824,17 +821,17 @@ create({ constructor: SourcesView, proto }, /** * Listener handling the "disableSelf" menuitem command. * * @param object aDetails * The breakpoint details (sourceLocation, lineNumber etc.). */ - _onDisableSelf: function DVS__onDisableSelf(aDetails) { + _onDisableSelf: function(aDetails) { let { sourceLocation: url, lineNumber: line, actor } = aDetails; if (this.disableBreakpoint(url, line)) { let prefix = "bp-cMenu-"; // "breakpoints context menu" let enableSelfId = prefix + "enableSelf-" + actor + "-menuitem"; let disableSelfId = prefix + "disableSelf-" + actor + "-menuitem"; document.getElementById(enableSelfId).removeAttribute("hidden"); document.getElementById(disableSelfId).setAttribute("hidden", "true"); @@ -842,110 +839,110 @@ create({ constructor: SourcesView, proto }, /** * Listener handling the "deleteSelf" menuitem command. * * @param object aDetails * The breakpoint details (sourceLocation, lineNumber etc.). */ - _onDeleteSelf: function DVS__onDeleteSelf(aDetails) { + _onDeleteSelf: function(aDetails) { let { sourceLocation: url, lineNumber: line } = aDetails; let breakpointClient = DebuggerController.Breakpoints.getBreakpoint(url, line); this.removeBreakpoint(url, line); DebuggerController.Breakpoints.removeBreakpoint(breakpointClient); }, /** * Listener handling the "enableOthers" menuitem command. * * @param object aDetails * The breakpoint details (sourceLocation, lineNumber etc.). */ - _onEnableOthers: function DVS__onEnableOthers(aDetails) { + _onEnableOthers: function(aDetails) { for (let [, item] of this._breakpointsCache) { if (item.attachment.actor != aDetails.actor) { this._onEnableSelf(item.attachment); } } }, /** * Listener handling the "disableOthers" menuitem command. * * @param object aDetails * The breakpoint details (sourceLocation, lineNumber etc.). */ - _onDisableOthers: function DVS__onDisableOthers(aDetails) { + _onDisableOthers: function(aDetails) { for (let [, item] of this._breakpointsCache) { if (item.attachment.actor != aDetails.actor) { this._onDisableSelf(item.attachment); } } }, /** * Listener handling the "deleteOthers" menuitem command. * * @param object aDetails * The breakpoint details (sourceLocation, lineNumber etc.). */ - _onDeleteOthers: function DVS__onDeleteOthers(aDetails) { + _onDeleteOthers: function(aDetails) { for (let [, item] of this._breakpointsCache) { if (item.attachment.actor != aDetails.actor) { this._onDeleteSelf(item.attachment); } } }, /** * Listener handling the "enableAll" menuitem command. * * @param object aDetails * The breakpoint details (sourceLocation, lineNumber etc.). */ - _onEnableAll: function DVS__onEnableAll(aDetails) { + _onEnableAll: function(aDetails) { this._onEnableOthers(aDetails); this._onEnableSelf(aDetails); }, /** * Listener handling the "disableAll" menuitem command. * * @param object aDetails * The breakpoint details (sourceLocation, lineNumber etc.). */ - _onDisableAll: function DVS__onDisableAll(aDetails) { + _onDisableAll: function(aDetails) { this._onDisableOthers(aDetails); this._onDisableSelf(aDetails); }, /** * Listener handling the "deleteAll" menuitem command. * * @param object aDetails * The breakpoint details (sourceLocation, lineNumber etc.). */ - _onDeleteAll: function DVS__onDeleteAll(aDetails) { + _onDeleteAll: function(aDetails) { this._onDeleteOthers(aDetails); this._onDeleteSelf(aDetails); }, /** * Gets an identifier for a breakpoint's details in the current cache. * * @param string aSourceLocation * The breakpoint source location. * @param number aLineNumber * The breakpoint line number. * @return string * The breakpoint identifier. */ - _getBreakpointKey: function DVS__getBreakpointKey(aSourceLocation, aLineNumber) { + _getBreakpointKey: function(aSourceLocation, aLineNumber) { return [aSourceLocation, aLineNumber].join(); }, _breakpointsCache: null, _commandset: null, _popupset: null, _cmPopup: null, _cbPanel: null, @@ -962,30 +959,30 @@ let SourceUtils = { _labelsCache: new Map(), // Can't use WeakMaps because keys are strings. _groupsCache: new Map(), /** * Clears the labels cache, populated by methods like * SourceUtils.getSourceLabel or Source Utils.getSourceGroup. * This should be done every time the content location changes. */ - clearCache: function SU_clearCache() { + clearCache: function() { this._labelsCache.clear(); this._groupsCache.clear(); }, /** * Gets a unique, simplified label from a source url. * * @param string aUrl * The source url. * @return string * The simplified label. */ - getSourceLabel: function SU_getSourceLabel(aUrl) { + getSourceLabel: function(aUrl) { let cachedLabel = this._labelsCache.get(aUrl); if (cachedLabel) { return cachedLabel; } let sourceLabel = this.trimUrl(aUrl); let unicodeLabel = NetworkHelper.convertToUnicode(unescape(sourceLabel)); this._labelsCache.set(aUrl, unicodeLabel); @@ -996,17 +993,17 @@ let SourceUtils = { * Gets as much information as possible about the hostname and directory paths * of an url to create a short url group identifier. * * @param string aUrl * The source url. * @return string * The simplified group. */ - getSourceGroup: function SU_getSourceGroup(aUrl) { + getSourceGroup: function(aUrl) { let cachedGroup = this._groupsCache.get(aUrl); if (cachedGroup) { return cachedGroup; } try { // Use an nsIURL to parse all the url path parts. var uri = Services.io.newURI(aUrl, null, null).QueryInterface(Ci.nsIURL); @@ -1049,17 +1046,17 @@ let SourceUtils = { * The source url. * @param number aLength [optional] * The expected source url length. * @param number aSection [optional] * The section to trim. Supported values: "start", "center", "end" * @return string * The shortened url. */ - trimUrlLength: function SU_trimUrlLength(aUrl, aLength, aSection) { + trimUrlLength: function(aUrl, aLength, aSection) { aLength = aLength || SOURCE_URL_DEFAULT_MAX_LENGTH; aSection = aSection || "end"; if (aUrl.length > aLength) { switch (aSection) { case "start": return L10N.ellipsis + aUrl.slice(-aLength); break; @@ -1077,17 +1074,17 @@ let SourceUtils = { /** * Trims the query part or reference identifier of a url string, if necessary. * * @param string aUrl * The source url. * @return string * The shortened url. */ - trimUrlQuery: function SU_trimUrlQuery(aUrl) { + trimUrlQuery: function(aUrl) { let length = aUrl.length; let q1 = aUrl.indexOf('?'); let q2 = aUrl.indexOf('&'); let q3 = aUrl.indexOf('#'); let q = Math.min(q1 != -1 ? q1 : length, q2 != -1 ? q2 : length, q3 != -1 ? q3 : length); @@ -1102,17 +1099,17 @@ let SourceUtils = { * The source url. * @param string aLabel [optional] * The resulting label at each step. * @param number aSeq [optional] * The current iteration step. * @return string * The resulting label at the final step. */ - trimUrl: function SU_trimUrl(aUrl, aLabel, aSeq) { + trimUrl: function(aUrl, aLabel, aSeq) { if (!(aUrl instanceof Ci.nsIURL)) { try { // Use an nsIURL to parse all the url path parts. aUrl = Services.io.newURI(aUrl, null, null).QueryInterface(Ci.nsIURL); } catch (e) { // This doesn't look like a url, or nsIURL can't handle it. return aUrl; } @@ -1199,44 +1196,44 @@ function WatchExpressionsView() { this._onBlur = this._onBlur.bind(this); this._onKeyPress = this._onKeyPress.bind(this); } create({ constructor: WatchExpressionsView, proto: MenuContainer.prototype }, { /** * Initialization function, called when the debugger is started. */ - initialize: function DVWE_initialize() { + initialize: function() { dumpn("Initializing the WatchExpressionsView"); this.node = new ListWidget(document.getElementById("expressions")); this._variables = document.getElementById("variables"); this.node.permaText = L10N.getStr("addWatchExpressionText"); this.node.itemFactory = this._createItemView; this.node.setAttribute("context", "debuggerWatchExpressionsContextMenu"); this.node.addEventListener("click", this._onClick, false); }, /** * Destruction function, called when the debugger is closed. */ - destroy: function DVWE_destroy() { + destroy: function() { dumpn("Destroying the WatchExpressionsView"); this.node.removeEventListener("click", this._onClick, false); }, /** * Adds a watch expression in this container. * * @param string aExpression [optional] * An optional initial watch expression text. */ - addExpression: function DVWE_addExpression(aExpression = "") { + addExpression: function(aExpression = "") { // Watch expressions are UI elements which benefit from visible panes. DebuggerView.showInstrumentsPane(); // Append a watch expression item to this container. let expressionItem = this.push([, aExpression], { index: 0, /* specifies on which position should the item be appended */ relaxed: true, /* this container should allow dupes & degenerates */ attachment: { @@ -1255,32 +1252,32 @@ create({ constructor: WatchExpressionsVi }, /** * Removes the watch expression with the specified index from this container. * * @param number aIndex * The index used to identify the watch expression. */ - removeExpressionAt: function DVWE_removeExpressionAt(aIndex) { + removeExpressionAt: function(aIndex) { this.remove(this._cache[aIndex]); this._cache.splice(aIndex, 1); }, /** * Changes the watch expression corresponding to the specified variable item. * This function is called whenever a watch expression's code is edited in * the variables view container. * * @param Variable aVar * The variable representing the watch expression evaluation. * @param string aExpression * The new watch expression text. */ - switchExpression: function DVWE_switchExpression(aVar, aExpression) { + switchExpression: function(aVar, aExpression) { let expressionItem = [i for (i of this._cache) if (i.attachment.currentExpression == aVar.name)][0]; // Remove the watch expression if it's going to be empty or a duplicate. if (!aExpression || this.getExpressions().indexOf(aExpression) != -1) { this.deleteExpression(aVar); return; } @@ -1296,17 +1293,17 @@ create({ constructor: WatchExpressionsVi /** * Removes the watch expression corresponding to the specified variable item. * This function is called whenever a watch expression's value is edited in * the variables view container. * * @param Variable aVar * The variable representing the watch expression evaluation. */ - deleteExpression: function DVWE_deleteExpression(aVar) { + deleteExpression: function(aVar) { let expressionItem = [i for (i of this._cache) if (i.attachment.currentExpression == aVar.name)][0]; // Remove the watch expression at its respective index. this.removeExpressionAt(this._cache.indexOf(expressionItem)); // Synchronize with the controller's watch expressions store. DebuggerController.StackFrames.syncWatchExpressions(); @@ -1315,39 +1312,39 @@ create({ constructor: WatchExpressionsVi /** * Gets the watch expression code string for an item in this container. * * @param number aIndex * The index used to identify the watch expression. * @return string * The watch expression code string. */ - getExpression: function DVWE_getExpression(aIndex) { + getExpression: function(aIndex) { return this._cache[aIndex].attachment.currentExpression; }, /** * Gets the watch expressions code strings for all items in this container. * * @return array * The watch expressions code strings. */ - getExpressions: function DVWE_getExpressions() { + getExpressions: function() { return [item.attachment.currentExpression for (item of this._cache)]; }, /** * Customization function for creating an item's UI. * * @param nsIDOMNode aElementNode * The element associated with the displayed item. * @param any aAttachment * Some attached primitive/object. */ - _createItemView: function DVWE__createItemView(aElementNode, aAttachment) { + _createItemView: function(aElementNode, aAttachment) { let arrowNode = document.createElement("box"); arrowNode.className = "dbg-expression-arrow"; let inputNode = document.createElement("textbox"); inputNode.className = "plain dbg-expression-input"; inputNode.setAttribute("value", aAttachment.initialExpression); inputNode.setAttribute("flex", "1"); @@ -1368,69 +1365,69 @@ create({ constructor: WatchExpressionsVi aAttachment.arrowNode = arrowNode; aAttachment.inputNode = inputNode; aAttachment.closeNode = closeNode; }, /** * Called when the add watch expression key sequence was pressed. */ - _onCmdAddExpression: function BP__onCmdAddExpression(aText) { + _onCmdAddExpression: function(aText) { // Only add a new expression if there's no pending input. if (this.getExpressions().indexOf("") == -1) { this.addExpression(aText || DebuggerView.editor.getSelectedText()); } }, /** * Called when the remove all watch expressions key sequence was pressed. */ - _onCmdRemoveAllExpressions: function BP__onCmdRemoveAllExpressions() { + _onCmdRemoveAllExpressions: function() { // Empty the view of all the watch expressions and clear the cache. this.empty(); this._cache.length = 0; // Synchronize with the controller's watch expressions store. DebuggerController.StackFrames.syncWatchExpressions(); }, /** * The click listener for this container. */ - _onClick: function DVWE__onClick(e) { + _onClick: function(e) { if (e.button != 0) { // Only allow left-click to trigger this event. return; } let expressionItem = this.getItemForElement(e.target); if (!expressionItem) { // The container is empty or we didn't click on an actual item. this.addExpression(); } }, /** * The click listener for a watch expression's close button. */ - _onClose: function DVWE__onClose(e) { + _onClose: function(e) { let expressionItem = this.getItemForElement(e.target); this.removeExpressionAt(this._cache.indexOf(expressionItem)); // Synchronize with the controller's watch expressions store. DebuggerController.StackFrames.syncWatchExpressions(); // Prevent clicking the expression element itself. e.preventDefault(); e.stopPropagation(); }, /** * The blur listener for a watch expression's textbox. */ - _onBlur: function DVWE__onBlur({ target: textbox }) { + _onBlur: function({ target: textbox }) { let expressionItem = this.getItemForElement(textbox); let oldExpression = expressionItem.attachment.currentExpression; let newExpression = textbox.value.trim(); // Remove the watch expression if it's empty. if (!newExpression) { this.removeExpressionAt(this._cache.indexOf(expressionItem)); } @@ -1445,33 +1442,33 @@ create({ constructor: WatchExpressionsVi // Synchronize with the controller's watch expressions store. DebuggerController.StackFrames.syncWatchExpressions(); }, /** * The keypress listener for a watch expression's textbox. */ - _onKeyPress: function DVWE__onKeyPress(e) { + _onKeyPress: function(e) { switch(e.keyCode) { case e.DOM_VK_RETURN: case e.DOM_VK_ENTER: case e.DOM_VK_ESCAPE: DebuggerView.editor.focus(); return; } }, /** * Gets an identifier for a new watch expression item in the current cache. * @return string */ _generateId: (function() { let count = 0; - return function DVWE__generateId() { + return function() { return (++count) + ""; }; })(), _variables: null, _cache: null }); @@ -1489,31 +1486,31 @@ function GlobalSearchView() { this._onLineClick = this._onLineClick.bind(this); this._onMatchClick = this._onMatchClick.bind(this); } create({ constructor: GlobalSearchView, proto: MenuContainer.prototype }, { /** * Initialization function, called when the debugger is started. */ - initialize: function DVGS_initialize() { + initialize: function() { dumpn("Initializing the GlobalSearchView"); this.node = new ListWidget(document.getElementById("globalsearch")); this._splitter = document.querySelector("#globalsearch + .devtools-horizontal-splitter"); this.node.emptyText = L10N.getStr("noMatchingStringsText"); this.node.itemFactory = this._createItemView; this.node.addEventListener("scroll", this._onScroll, false); }, /** * Destruction function, called when the debugger is closed. */ - destroy: function DVGS_destroy() { + destroy: function() { dumpn("Destroying the GlobalSearchView"); this.node.removeEventListener("scroll", this._onScroll, false); }, /** * Gets the visibility state of the global search container. * @return boolean @@ -1529,42 +1526,42 @@ create({ constructor: GlobalSearchView, set hidden(aFlag) { this.node.setAttribute("hidden", aFlag); this._splitter.setAttribute("hidden", aFlag); }, /** * Hides and removes all items from this search container. */ - clearView: function DVGS_clearView() { + clearView: function() { this.hidden = true; this.empty(); window.dispatchEvent(document, "Debugger:GlobalSearch:ViewCleared"); }, /** * Focuses the next found match in the source editor. */ - focusNextMatch: function DVGS_focusNextMatch() { + focusNextMatch: function() { let totalLineResults = LineResults.size(); if (!totalLineResults) { return; } if (++this._currentlyFocusedMatch >= totalLineResults) { this._currentlyFocusedMatch = 0; } this._onMatchClick({ target: LineResults.getElementAtIndex(this._currentlyFocusedMatch) }); }, /** * Focuses the previously found match in the source editor. */ - focusPrevMatch: function DVGS_focusPrevMatch() { + focusPrevMatch: function() { let totalLineResults = LineResults.size(); if (!totalLineResults) { return; } if (--this._currentlyFocusedMatch < 0) { this._currentlyFocusedMatch = totalLineResults - 1; } this._onMatchClick({ @@ -1578,17 +1575,17 @@ create({ constructor: GlobalSearchView, delayedSearch: true, /** * Schedules searching for a string in all of the sources. * * @param string aQuery * The string to search for. */ - scheduleSearch: function DVGS_scheduleSearch(aQuery) { + scheduleSearch: function(aQuery) { if (!this.delayedSearch) { this.performSearch(aQuery); return; } let delay = Math.max(GLOBAL_SEARCH_ACTION_MAX_DELAY / aQuery.length, 0); window.clearTimeout(this._searchTimeout); this._searchFunction = this._startSearch.bind(this, aQuery); @@ -1596,41 +1593,41 @@ create({ constructor: GlobalSearchView, }, /** * Immediately searches for a string in all of the sources. * * @param string aQuery * The string to search for. */ - performSearch: function DVGS_performSearch(aQuery) { + performSearch: function(aQuery) { window.clearTimeout(this._searchTimeout); this._searchFunction = null; this._startSearch(aQuery); }, /** * Starts searching for a string in all of the sources. * * @param string aQuery * The string to search for. */ - _startSearch: function DVGS__startSearch(aQuery) { + _startSearch: function(aQuery) { this._searchedToken = aQuery; DebuggerController.SourceScripts.fetchSources(DebuggerView.Sources.values, { onFinished: this._performGlobalSearch }); }, /** * Finds string matches in all the sources stored in the controller's cache, * and groups them by location and line number. */ - _performGlobalSearch: function DVGS__performGlobalSearch() { + _performGlobalSearch: function() { // Get the currently searched token from the filtering input. let token = this._searchedToken; // Make sure we're actually searching for something. if (!token) { this.clearView(); window.dispatchEvent(document, "Debugger:GlobalSearch:TokenEmpty"); return; @@ -1706,17 +1703,17 @@ create({ constructor: GlobalSearchView, }, /** * Creates global search results entries and adds them to this container. * * @param GlobalResults aGlobalResults * An object containing all source results, grouped by source location. */ - _createGlobalResultsUI: function DVGS__createGlobalResultsUI(aGlobalResults) { + _createGlobalResultsUI: function(aGlobalResults) { let i = 0; for (let [location, sourceResults] in aGlobalResults) { if (i++ == 0) { this._createSourceResultsUI(location, sourceResults, true); } else { // Dispatch subsequent document manipulation operations, to avoid // blocking the main thread when a large number of search results @@ -1732,18 +1729,17 @@ create({ constructor: GlobalSearchView, * * @param string aLocation * The location of the source. * @param SourceResults aSourceResults * An object containing all the matched lines for a specific source. * @param boolean aExpandFlag * True to expand the source results. */ - _createSourceResultsUI: - function DVGS__createSourceResultsUI(aLocation, aSourceResults, aExpandFlag) { + _createSourceResultsUI: function(aLocation, aSourceResults, aExpandFlag) { // Append a source results item to this container. let sourceResultsItem = this.push([aLocation, aSourceResults.matchCount], { index: -1, /* specifies on which position should the item be appended */ relaxed: true, /* this container should allow dupes & degenerates */ attachment: { sourceResults: aSourceResults, expandFlag: aExpandFlag } @@ -1757,47 +1753,46 @@ create({ constructor: GlobalSearchView, * The element associated with the displayed item. * @param any aAttachment * Some attached primitive/object. * @param string aLocation * The source result's location. * @param string aMatchCount * The source result's match count. */ - _createItemView: - function DVGS__createItemView(aElementNode, aAttachment, aLocation, aMatchCount) { + _createItemView: function(aElementNode, aAttachment, aLocation, aMatchCount) { let { sourceResults, expandFlag } = aAttachment; sourceResults.createView(aElementNode, aLocation, aMatchCount, expandFlag, { onHeaderClick: this._onHeaderClick, onLineClick: this._onLineClick, onMatchClick: this._onMatchClick }); }, /** * The click listener for a results header. */ - _onHeaderClick: function DVGS__onHeaderClick(e) { + _onHeaderClick: function(e) { let sourceResultsItem = SourceResults.getItemForElement(e.target); sourceResultsItem.instance.toggle(e); }, /** * The click listener for a results line. */ - _onLineClick: function DVGLS__onLineClick(e) { + _onLineClick: function(e) { let lineResultsItem = LineResults.getItemForElement(e.target); this._onMatchClick({ target: lineResultsItem.firstMatch }); }, /** * The click listener for a result match. */ - _onMatchClick: function DVGLS__onMatchClick(e) { + _onMatchClick: function(e) { if (e instanceof Event) { e.preventDefault(); e.stopPropagation(); } let target = e.target; let sourceResultsItem = SourceResults.getItemForElement(target); let lineResultsItem = LineResults.getItemForElement(target); @@ -1814,29 +1809,29 @@ create({ constructor: GlobalSearchView, let offset = editor.getCaretOffset(); let { start, length } = lineResultsItem.lineData.range; editor.setSelection(offset + start, offset + start + length); }, /** * The scroll listener for the global search container. */ - _onScroll: function DVGS__onScroll(e) { + _onScroll: function(e) { for (let item in this) { this._expandResultsIfNeeded(item.target); } }, /** * Expands the source results it they are currently visible. * * @param nsIDOMNode aTarget * The element associated with the displayed item. */ - _expandResultsIfNeeded: function DVGS__expandResultsIfNeeded(aTarget) { + _expandResultsIfNeeded: function(aTarget) { let sourceResultsItem = SourceResults.getItemForElement(aTarget); if (sourceResultsItem.instance.toggled || sourceResultsItem.instance.expanded) { return; } let { top, height } = aTarget.getBoundingClientRect(); let { clientHeight } = this.node._parent; @@ -1846,28 +1841,28 @@ create({ constructor: GlobalSearchView, }, /** * Scrolls a match into view if not already visible. * * @param nsIDOMNode aMatch * The match to scroll into view. */ - _scrollMatchIntoViewIfNeeded: function DVGS__scrollMatchIntoViewIfNeeded(aMatch) { + _scrollMatchIntoViewIfNeeded: function(aMatch) { let boxObject = this.node._parent.boxObject.QueryInterface(Ci.nsIScrollBoxObject); boxObject.ensureElementIsVisible(aMatch); }, /** * Starts a bounce animation for a match. * * @param nsIDOMNode aMatch * The match to start a bounce animation for. */ - _bounceMatch: function DVGS__bounceMatch(aMatch) { + _bounceMatch: function(aMatch) { Services.tm.currentThread.dispatch({ run: function() { aMatch.addEventListener("transitionend", function onEvent() { aMatch.removeEventListener("transitionend", onEvent); aMatch.removeAttribute("focused"); }); aMatch.setAttribute("focused", ""); }}, 0); aMatch.setAttribute("focusing", ""); @@ -1895,17 +1890,17 @@ GlobalResults.prototype = { /** * Adds source results to this store. * * @param string aLocation * The location of the source. * @param SourceResults aSourceResults * An object containing all the matched lines for a specific source. */ - add: function GR_add(aLocation, aSourceResults) { + add: function(aLocation, aSourceResults) { this._store.set(aLocation, aSourceResults); }, /** * Gets the number of source results in this store. */ get itemCount() this._store.size, @@ -1925,45 +1920,45 @@ SourceResults.prototype = { /** * Adds line results to this store. * * @param number aLineNumber * The line location in the source. * @param LineResults aLineResults * An object containing all the matches for a specific line. */ - add: function SR_add(aLineNumber, aLineResults) { + add: function(aLineNumber, aLineResults) { this._store.set(aLineNumber, aLineResults); }, /** * The number of matches in this store. One line may have multiple matches. */ matchCount: -1, /** * Expands the element, showing all the added details. */ - expand: function SR_expand() { + expand: function() { this._target.resultsContainer.removeAttribute("hidden") this._target.arrow.setAttribute("open", ""); }, /** * Collapses the element, hiding all the added details. */ - collapse: function SR_collapse() { + collapse: function() { this._target.resultsContainer.setAttribute("hidden", "true"); this._target.arrow.removeAttribute("open"); }, /** * Toggles between the element collapse/expand state. */ - toggle: function SR_toggle(e) { + toggle: function(e) { if (e instanceof Event) { this._userToggled = true; } this.expanded ^= 1; }, /** * Relaxes the auto-expand rules to always show as many results as possible. @@ -2007,18 +2002,17 @@ SourceResults.prototype = { * The source result's match count. * @param boolean aExpandFlag * True to expand the source results. * @param object aCallbacks * An object containing all the necessary callback functions: * - onHeaderClick * - onMatchClick */ - createView: - function SR_createView(aElementNode, aLocation, aMatchCount, aExpandFlag, aCallbacks) { + createView: function(aElementNode, aLocation, aMatchCount, aExpandFlag, aCallbacks) { this._target = aElementNode; let arrow = document.createElement("box"); arrow.className = "arrow"; let locationNode = document.createElement("label"); locationNode.className = "plain dbg-results-header-location"; locationNode.setAttribute("value", SourceUtils.trimUrlLength(aLocation)); @@ -2088,17 +2082,17 @@ LineResults.prototype = { * * @param string aString * The text contents chunk in the line. * @param object aRange * An object containing the { start, length } of the chunk. * @param boolean aMatchFlag * True if the chunk is a matched string, false if just text content. */ - add: function LC_add(aString, aRange, aMatchFlag) { + add: function(aString, aRange, aMatchFlag) { this._store.push({ string: aString, range: aRange, match: !!aMatchFlag }); }, /** @@ -2114,17 +2108,17 @@ LineResults.prototype = { * The element associated with the displayed item. * @param number aLineNumber * The line location in the source. * @param object aCallbacks * An object containing all the necessary callback functions: * - onMatchClick * - onLineClick */ - createView: function LR_createView(aContainer, aLineNumber, aCallbacks) { + createView: function(aContainer, aLineNumber, aCallbacks) { this._target = aContainer; let lineNumberNode = document.createElement("label"); let lineContentsNode = document.createElement("hbox"); let lineString = ""; let lineLength = 0; let firstMatch = null; @@ -2166,29 +2160,29 @@ LineResults.prototype = { }, /** * Handles a match while creating the view. * @param number aLineNumber * @param nsIDOMNode aNode * @param object aMatchChunk */ - _entangleMatch: function LR__entangleMatch(aLineNumber, aNode, aMatchChunk) { + _entangleMatch: function(aLineNumber, aNode, aMatchChunk) { LineResults._itemsByElement.set(aNode, { lineNumber: aLineNumber, lineData: aMatchChunk }); }, /** * Handles a line while creating the view. * @param nsIDOMNode aNode * @param nsIDOMNode aFirstMatch */ - _entangleLine: function LR__entangleLine(aNode, aFirstMatch) { + _entangleLine: function(aNode, aFirstMatch) { LineResults._itemsByElement.set(aNode, { firstMatch: aFirstMatch, nonenumerable: true }); }, /** * An nsIDOMNode label with an ellipsis value. @@ -2204,45 +2198,45 @@ LineResults.prototype = { _target: null }; /** * A generator-iterator over the global, source or line results. */ GlobalResults.prototype.__iterator__ = SourceResults.prototype.__iterator__ = -LineResults.prototype.__iterator__ = function DVGS_iterator() { +LineResults.prototype.__iterator__ = function() { for (let item of this._store) { yield item; } }; /** * Gets the item associated with the specified element. * * @param nsIDOMNode aElement * The element used to identify the item. * @return object * The matched item, or null if nothing is found. */ SourceResults.getItemForElement = -LineResults.getItemForElement = function DVGS_getItemForElement(aElement) { +LineResults.getItemForElement = function(aElement) { return MenuContainer.prototype.getItemForElement.call(this, aElement); }; /** * Gets the element associated with a particular item at a specified index. * * @param number aIndex * The index used to identify the item. * @return nsIDOMNode * The matched element, or null if nothing is found. */ SourceResults.getElementAtIndex = -LineResults.getElementAtIndex = function DVGS_getElementAtIndex(aIndex) { +LineResults.getElementAtIndex = function(aIndex) { for (let [element, item] of this._itemsByElement) { if (!item.nonenumerable && !aIndex--) { return element; } } return null; }; @@ -2250,17 +2244,17 @@ LineResults.getElementAtIndex = function * Gets the index of an item associated with the specified element. * * @param nsIDOMNode aElement * The element to get the index for. * @return number * The index of the matched element, or -1 if nothing is found. */ SourceResults.indexOfElement = -LineResults.indexOfElement = function DVGS_indexOFElement(aElement) { +LineResults.indexOfElement = function(aElement) { let count = 0; for (let [element, item] of this._itemsByElement) { if (element == aElement) { return count; } if (!item.nonenumerable) { count++; } @@ -2270,17 +2264,17 @@ LineResults.indexOfElement = function DV /** * Gets the number of cached items associated with a specified element. * * @return number * The number of key/value pairs in the corresponding map. */ SourceResults.size = -LineResults.size = function DVGS_size() { +LineResults.size = function() { let count = 0; for (let [, item] of this._itemsByElement) { if (!item.nonenumerable) { count++; } } return count; };
--- a/browser/devtools/debugger/debugger-toolbar.js +++ b/browser/devtools/debugger/debugger-toolbar.js @@ -18,17 +18,17 @@ function ToolbarView() { this._onStepInPressed = this._onStepInPressed.bind(this); this._onStepOutPressed = this._onStepOutPressed.bind(this); } ToolbarView.prototype = { /** * Initialization function, called when the debugger is started. */ - initialize: function DVT_initialize() { + initialize: function() { dumpn("Initializing the ToolbarView"); this._instrumentsPaneToggleButton = document.getElementById("instruments-pane-toggle"); this._resumeOrderPanel = document.getElementById("resumption-order-panel"); this._resumeButton = document.getElementById("resume"); this._stepOverButton = document.getElementById("step-over"); this._stepInButton = document.getElementById("step-in"); this._stepOutButton = document.getElementById("step-out"); @@ -56,33 +56,33 @@ ToolbarView.prototype = { // TODO: bug 806775 // this.toggleChromeGlobalsContainer(window._isChromeDebugger); }, /** * Destruction function, called when the debugger is closed. */ - destroy: function DVT_destroy() { + destroy: function() { dumpn("Destroying the ToolbarView"); this._instrumentsPaneToggleButton.removeEventListener("mousedown", this._onTogglePanesPressed, false); this._resumeButton.removeEventListener("mousedown", this._onResumePressed, false); this._stepOverButton.removeEventListener("mousedown", this._onStepOverPressed, false); this._stepInButton.removeEventListener("mousedown", this._onStepInPressed, false); this._stepOutButton.removeEventListener("mousedown", this._onStepOutPressed, false); }, /** * Sets the resume button state based on the debugger active thread. * * @param string aState * Either "paused" or "attached". */ - toggleResumeButtonState: function DVT_toggleResumeButtonState(aState) { + toggleResumeButtonState: function(aState) { // If we're paused, check and show a resume label on the button. if (aState == "paused") { this._resumeButton.setAttribute("checked", "true"); this._resumeButton.setAttribute("tooltiptext", this._resumeTooltip); } // If we're attached, do the opposite. else if (aState == "attached") { this._resumeButton.removeAttribute("checked"); @@ -92,77 +92,77 @@ ToolbarView.prototype = { /** * Display a warning when trying to resume a debuggee while another is paused. * Debuggees must be unpaused in a Last-In-First-Out order. * * @param string aPausedUrl * The URL of the last paused debuggee. */ - showResumeWarning: function DVT_showResumeWarning(aPausedUrl) { + showResumeWarning: function(aPausedUrl) { let label = L10N.getFormatStr("resumptionOrderPanelTitle", [aPausedUrl]); document.getElementById("resumption-panel-desc").textContent = label; this._resumeOrderPanel.openPopup(this._resumeButton); }, /** * Sets the chrome globals container hidden or visible. It's hidden by default. * * @param boolean aVisibleFlag * Specifies the intended visibility. */ - toggleChromeGlobalsContainer: function DVT_toggleChromeGlobalsContainer(aVisibleFlag) { + toggleChromeGlobalsContainer: function(aVisibleFlag) { this._chromeGlobals.setAttribute("hidden", !aVisibleFlag); }, /** * Listener handling the toggle button click event. */ - _onTogglePanesPressed: function DVT__onTogglePanesPressed() { + _onTogglePanesPressed: function() { DebuggerView.toggleInstrumentsPane({ visible: DebuggerView.instrumentsPaneHidden, animated: true, delayed: true }); }, /** * Listener handling the pause/resume button click event. */ - _onResumePressed: function DVT__onResumePressed() { + _onResumePressed: function() { if (DebuggerController.activeThread.paused) { let warn = DebuggerController._ensureResumptionOrder; DebuggerController.activeThread.resume(warn); } else { DebuggerController.activeThread.interrupt(); } }, /** * Listener handling the step over button click event. */ - _onStepOverPressed: function DVT__onStepOverPressed() { + _onStepOverPressed: function() { if (DebuggerController.activeThread.paused) { DebuggerController.activeThread.stepOver(); } }, /** * Listener handling the step in button click event. */ - _onStepInPressed: function DVT__onStepInPressed() { + _onStepInPressed: function() { if (DebuggerController.activeThread.paused) { DebuggerController.activeThread.stepIn(); } }, /** * Listener handling the step out button click event. */ - _onStepOutPressed: function DVT__onStepOutPressed() { + _onStepOutPressed: function() { if (DebuggerController.activeThread.paused) { DebuggerController.activeThread.stepOut(); } }, _instrumentsPaneToggleButton: null, _resumeOrderPanel: null, _resumeButton: null, @@ -189,17 +189,17 @@ function OptionsView() { this._toggleShowVariablesFilterBox = this._toggleShowVariablesFilterBox.bind(this); this._toggleShowOriginalSource = this._toggleShowOriginalSource.bind(this); } OptionsView.prototype = { /** * Initialization function, called when the debugger is started. */ - initialize: function DVO_initialize() { + initialize: function() { dumpn("Initializing the OptionsView"); this._button = document.getElementById("debugger-options"); this._pauseOnExceptionsItem = document.getElementById("pause-on-exceptions"); this._showPanesOnStartupItem = document.getElementById("show-panes-on-startup"); this._showVariablesOnlyEnumItem = document.getElementById("show-vars-only-enum"); this._showVariablesFilterBoxItem = document.getElementById("show-vars-filter-box"); this._showOriginalSourceItem = document.getElementById("show-original-source"); @@ -209,71 +209,71 @@ OptionsView.prototype = { this._showVariablesOnlyEnumItem.setAttribute("checked", Prefs.variablesOnlyEnumVisible); this._showVariablesFilterBoxItem.setAttribute("checked", Prefs.variablesSearchboxVisible); this._showOriginalSourceItem.setAttribute("checked", Prefs.sourceMapsEnabled); }, /** * Destruction function, called when the debugger is closed. */ - destroy: function DVO_destroy() { + destroy: function() { dumpn("Destroying the OptionsView"); // Nothing to do here yet. }, /** * Listener handling the 'gear menu' popup showing event. */ - _onPopupShowing: function DVO__onPopupShowing() { + _onPopupShowing: function() { this._button.setAttribute("open", "true"); }, /** * Listener handling the 'gear menu' popup hiding event. */ - _onPopupHiding: function DVO__onPopupHiding() { + _onPopupHiding: function() { this._button.removeAttribute("open"); }, /** * Listener handling the 'pause on exceptions' menuitem command. */ - _togglePauseOnExceptions: function DVO__togglePauseOnExceptions() { + _togglePauseOnExceptions: function() { DebuggerController.activeThread.pauseOnExceptions(Prefs.pauseOnExceptions = this._pauseOnExceptionsItem.getAttribute("checked") == "true"); }, /** * Listener handling the 'show panes on startup' menuitem command. */ - _toggleShowPanesOnStartup: function DVO__toggleShowPanesOnStartup() { + _toggleShowPanesOnStartup: function() { Prefs.panesVisibleOnStartup = this._showPanesOnStartupItem.getAttribute("checked") == "true"; }, /** * Listener handling the 'show non-enumerables' menuitem command. */ - _toggleShowVariablesOnlyEnum: function DVO__toggleShowVariablesOnlyEnum() { + _toggleShowVariablesOnlyEnum: function() { DebuggerView.Variables.onlyEnumVisible = Prefs.variablesOnlyEnumVisible = this._showVariablesOnlyEnumItem.getAttribute("checked") == "true"; }, /** * Listener handling the 'show variables searchbox' menuitem command. */ - _toggleShowVariablesFilterBox: function DVO__toggleShowVariablesFilterBox() { + _toggleShowVariablesFilterBox: function() { DebuggerView.Variables.searchEnabled = Prefs.variablesSearchboxVisible = this._showVariablesFilterBoxItem.getAttribute("checked") == "true"; }, /** * Listener handling the 'show original source' menuitem command. */ - _toggleShowOriginalSource: function DVO__toggleShowOriginalSource() { + _toggleShowOriginalSource: function() { let pref = Prefs.sourceMapsEnabled = this._showOriginalSourceItem.getAttribute("checked") == "true"; DebuggerController.reconfigureThread(pref); }, _button: null, _pauseOnExceptionsItem: null, @@ -292,54 +292,54 @@ function ChromeGlobalsView() { this._onSelect = this._onSelect.bind(this); this._onClick = this._onClick.bind(this); } create({ constructor: ChromeGlobalsView, proto: MenuContainer.prototype }, { /** * Initialization function, called when the debugger is started. */ - initialize: function DVCG_initialize() { + initialize: function() { dumpn("Initializing the ChromeGlobalsView"); this.node = document.getElementById("chrome-globals"); this.emptyText = L10N.getStr("noGlobalsText"); this.unavailableText = L10N.getStr("noMatchingGlobalsText"); this.node.addEventListener("select", this._onSelect, false); this.node.addEventListener("click", this._onClick, false); // Show an empty label by default. this.empty(); }, /** * Destruction function, called when the debugger is closed. */ - destroy: function DVT_destroy() { + destroy: function() { dumpn("Destroying the ChromeGlobalsView"); this.node.removeEventListener("select", this._onSelect, false); this.node.removeEventListener("click", this._onClick, false); }, /** * The select listener for the chrome globals container. */ - _onSelect: function DVCG__onSelect() { + _onSelect: function() { if (!this.refresh()) { return; } // TODO: bug 806775, do something useful for chrome debugging. }, /** * The click listener for the chrome globals container. */ - _onClick: function DVCG__onClick() { + _onClick: function() { // Use this container as a filtering target. DebuggerView.Filtering.target = this; } }); /** * Functions handling the stackframes UI. */ @@ -353,17 +353,17 @@ function StackFramesView() { this._afterScroll = this._afterScroll.bind(this); this._selectFrame = this._selectFrame.bind(this); } create({ constructor: StackFramesView, proto: MenuContainer.prototype }, { /** * Initialization function, called when the debugger is started. */ - initialize: function DVSF_initialize() { + initialize: function() { dumpn("Initializing the StackFramesView"); let commandset = this._commandset = document.createElement("commandset"); let menupopup = this._menupopup = document.createElement("menupopup"); commandset.id = "stackframesCommandset"; menupopup.id = "stackframesMenupopup"; document.getElementById("debuggerPopupset").appendChild(menupopup); @@ -373,17 +373,17 @@ create({ constructor: StackFramesView, p this.node.addEventListener("mousedown", this._onClick, false); this.node.addEventListener("scroll", this._onScroll, true); window.addEventListener("resize", this._onScroll, true); }, /** * Destruction function, called when the debugger is closed. */ - destroy: function DVSF_destroy() { + destroy: function() { dumpn("Destroying the StackFramesView"); this.node.removeEventListener("mousedown", this._onClick, false); this.node.removeEventListener("scroll", this._onScroll, true); window.removeEventListener("resize", this._onScroll, true); }, /** @@ -393,17 +393,17 @@ create({ constructor: StackFramesView, p * The frame title to be displayed in the list. * @param string aSourceLocation * The source location to be displayed in the list. * @param string aLineNumber * The line number to be displayed in the list. * @param number aDepth * The frame depth specified by the debugger. */ - addFrame: function DVSF_addFrame(aFrameTitle, aSourceLocation, aLineNumber, aDepth) { + addFrame: function(aFrameTitle, aSourceLocation, aLineNumber, aDepth) { // Create the element node and menu entry for the stack frame item. let frameView = this._createFrameView.apply(this, arguments); let menuEntry = this._createMenuEntry.apply(this, arguments); // Append a stack frame item to this container. let stackframeItem = this.push(frameView, { index: 0, /* specifies on which position should the item be appended */ attachment: { @@ -423,17 +423,17 @@ create({ constructor: StackFramesView, p }, /** * Highlights a frame in this stackframes container. * * @param number aDepth * The frame depth specified by the debugger controller. */ - highlightFrame: function DVSF_highlightFrame(aDepth) { + highlightFrame: function(aDepth) { let selectedItem = this.selectedItem = this._framesCache.get(aDepth); for (let item in this) { if (item != selectedItem) { item.attachment.popup.menuitem.removeAttribute("checked"); } else { item.attachment.popup.menuitem.setAttribute("checked", ""); } @@ -454,18 +454,17 @@ create({ constructor: StackFramesView, p * The source location to be displayed in the list. * @param string aLineNumber * The line number to be displayed in the list. * @param number aDepth * The frame depth specified by the debugger. * @return nsIDOMNode * The stack frame view. */ - _createFrameView: - function DVSF__createFrameView(aFrameTitle, aSourceLocation, aLineNumber, aDepth) { + _createFrameView: function(aFrameTitle, aSourceLocation, aLineNumber, aDepth) { let frameDetails = SourceUtils.trimUrlLength( SourceUtils.getSourceLabel(aSourceLocation), STACK_FRAMES_SOURCE_URL_MAX_LENGTH, STACK_FRAMES_SOURCE_URL_TRIM_SECTION) + SEARCH_LINE_FLAG + aLineNumber; let frameTitleNode = document.createElement("label"); frameTitleNode.className = "plain dbg-stackframe-title breadcrumbs-widget-item-tag"; @@ -494,18 +493,17 @@ create({ constructor: StackFramesView, p * The source location to be displayed in the list. * @param string aLineNumber * The line number to be displayed in the list. * @param number aDepth * The frame depth specified by the debugger. * @return object * An object containing the stack frame command and menu item. */ - _createMenuEntry: - function DVSF__createMenuEntry(aFrameTitle, aSourceLocation, aLineNumber, aDepth) { + _createMenuEntry: function(aFrameTitle, aSourceLocation, aLineNumber, aDepth) { let frameDescription = SourceUtils.trimUrlLength( SourceUtils.getSourceLabel(aSourceLocation), STACK_FRAMES_POPUP_SOURCE_URL_MAX_LENGTH, STACK_FRAMES_POPUP_SOURCE_URL_TRIM_SECTION) + SEARCH_LINE_FLAG + aLineNumber; let prefix = "sf-cMenu-"; // "stackframes context menu" let commandId = prefix + aDepth + "-" + "-command"; @@ -544,71 +542,71 @@ create({ constructor: StackFramesView, p }, /** * Destroys a context menu item for a stack frame. * * @param object aMenuEntry * An object containing the stack frame command and menu item. */ - _destroyMenuEntry: function DVSF__destroyMenuEntry(aMenuEntry) { + _destroyMenuEntry: function(aMenuEntry) { dumpn("Destroying context menu: " + aMenuEntry.command.id + " & " + aMenuEntry.menuitem.id); let command = aMenuEntry.command; let menuitem = aMenuEntry.menuitem; command.parentNode.removeChild(command); menuitem.parentNode.removeChild(menuitem); }, /** * Function called each time a stack frame item is removed. * * @param MenuItem aItem * The corresponding menu item. */ - _onStackframeRemoved: function DVSF__onStackframeRemoved(aItem) { + _onStackframeRemoved: function(aItem) { dumpn("Finalizing stackframe item: " + aItem); let { popup, depth } = aItem.attachment; this._destroyMenuEntry(popup); this._framesCache.delete(depth); }, /** * The click listener for the stackframes container. */ - _onClick: function DVSF__onClick(e) { + _onClick: function(e) { if (e && e.button != 0) { // Only allow left-click to trigger this event. return; } let item = this.getItemForElement(e.target); if (item) { // The container is not empty and we clicked on an actual item. this._selectFrame(item.attachment.depth); } }, /** * The scroll listener for the stackframes container. */ - _onScroll: function DVSF__onScroll() { + _onScroll: function() { // Update the stackframes container only if we have to. if (!this.dirty) { return; } window.clearTimeout(this._scrollTimeout); this._scrollTimeout = window.setTimeout(this._afterScroll, STACK_FRAMES_SCROLL_DELAY); }, /** * Requests the addition of more frames from the controller. */ - _afterScroll: function DVSF__afterScroll() { + _afterScroll: function() { let list = this.node._list; let scrollPosition = list.scrollPosition; let scrollWidth = list.scrollWidth; // If the stackframes container scrolled almost to the end, with only // 1/10 of a breadcrumb remaining, load more content. if (scrollPosition - scrollWidth / 10 < 1) { list.ensureElementIsVisible(this.getItemAtIndex(CALL_STACK_PAGE_SIZE - 1).target); @@ -620,17 +618,17 @@ create({ constructor: StackFramesView, p }, /** * Requests selection of a frame from the controller. * * @param number aDepth * The depth of the frame in the stack. */ - _selectFrame: function DVSF__selectFrame(aDepth) { + _selectFrame: function(aDepth) { DebuggerController.StackFrames.selectFrame(aDepth); }, _framesCache: null, _commandset: null, _menupopup: null, _scrollTimeout: null }); @@ -641,33 +639,33 @@ create({ constructor: StackFramesView, p let StackFrameUtils = { /** * Create a textual representation for the specified stack frame * to display in the stackframes container. * * @param object aFrame * The stack frame to label. */ - getFrameTitle: function SFU_getFrameTitle(aFrame) { + getFrameTitle: function(aFrame) { if (aFrame.type == "call") { let c = aFrame.callee; return (c.name || c.userDisplayName || c.displayName || "(anonymous)"); } return "(" + aFrame.type + ")"; }, /** * Constructs a scope label based on its environment. * * @param object aEnv * The scope's environment. * @return string * The scope's label. */ - getScopeLabel: function SFU_getScopeLabel(aEnv) { + getScopeLabel: function(aEnv) { let name = ""; // Name the outermost scope Global. if (!aEnv.parent) { name = L10N.getStr("globalScopeLabel"); } // Otherwise construct the scope name. else { @@ -702,17 +700,17 @@ function FilterView() { this._onKeyPress = this._onKeyPress.bind(this); this._onBlur = this._onBlur.bind(this); } FilterView.prototype = { /** * Initialization function, called when the debugger is started. */ - initialize: function DVF_initialize() { + initialize: function() { dumpn("Initializing the FilterView"); this._searchbox = document.getElementById("searchbox"); this._searchboxHelpPanel = document.getElementById("searchbox-help-panel"); this._globalOperatorButton = document.getElementById("global-operator-button"); this._globalOperatorLabel = document.getElementById("global-operator-label"); this._functionOperatorButton = document.getElementById("function-operator-button"); this._functionOperatorLabel = document.getElementById("function-operator-label"); @@ -759,17 +757,17 @@ FilterView.prototype = { // } else { this.target = DebuggerView.Sources; // } }, /** * Destruction function, called when the debugger is closed. */ - destroy: function DVF_destroy() { + destroy: function() { dumpn("Destroying the FilterView"); this._searchbox.removeEventListener("click", this._onClick, false); this._searchbox.removeEventListener("select", this._onSearch, false); this._searchbox.removeEventListener("input", this._onSearch, false); this._searchbox.removeEventListener("keypress", this._onKeyPress, false); this._searchbox.removeEventListener("blur", this._onBlur, false); }, @@ -875,28 +873,28 @@ FilterView.prototype = { * Returns the currently searched token. * @return string */ get searchedToken() this.searchboxInfo[3], /** * Clears the text from the searchbox and resets any changed view. */ - clearSearch: function DVF_clearSearch() { + clearSearch: function() { this._searchbox.value = ""; this._searchboxHelpPanel.hidePopup(); }, /** * Performs a file search if necessary. * * @param string aFile * The source location to search for. */ - _performFileSearch: function DVF__performFileSearch(aFile) { + _performFileSearch: function(aFile) { // Don't search for files if the input hasn't changed. if (this._prevSearchedFile == aFile) { return; } // This is the target container to be currently filtered. Clicking on a // container generally means it should become a target. let view = this._target; @@ -953,17 +951,17 @@ FilterView.prototype = { /** * Performs a line search if necessary. * (Jump to lines in the currently visible source). * * @param number aLine * The source line number to jump to. */ - _performLineSearch: function DVF__performLineSearch(aLine) { + _performLineSearch: function(aLine) { // Don't search for lines if the input hasn't changed. if (this._prevSearchedLine != aLine && aLine) { DebuggerView.editor.setCaretPosition(aLine - 1); } // Can't search for lines and tokens at the same time. if (this._prevSearchedToken && !aLine) { this._target.refresh(); } @@ -974,17 +972,17 @@ FilterView.prototype = { /** * Performs a token search if necessary. * (Search for tokens in the currently visible source). * * @param string aToken * The source token to find. */ - _performTokenSearch: function DVF__performTokenSearch(aToken) { + _performTokenSearch: function(aToken) { // Don't search for tokens if the input hasn't changed. if (this._prevSearchedToken != aToken && aToken) { let editor = DebuggerView.editor; let offset = editor.find(aToken, { ignoreCase: true }); if (offset > -1) { editor.setSelection(offset, offset + aToken.length) } } @@ -995,24 +993,24 @@ FilterView.prototype = { // Remember the previously searched token to avoid redundant filtering. this._prevSearchedToken = aToken; }, /** * The click listener for the search container. */ - _onClick: function DVF__onClick() { + _onClick: function() { this._searchboxHelpPanel.openPopup(this._searchbox); }, /** * The search listener for the search container. */ - _onSearch: function DVF__onScriptsSearch() { + _onSearch: function() { this._searchboxHelpPanel.hidePopup(); let [operator, file, line, token] = this.searchboxInfo; // If this is a global search, schedule it for when the user stops typing, // or hide the corresponding pane otherwise. if (operator == SEARCH_GLOBAL_FLAG) { DebuggerView.GlobalSearch.scheduleSearch(token); this._prevSearchedToken = token; @@ -1041,17 +1039,17 @@ FilterView.prototype = { this._performFileSearch(file); this._performLineSearch(line); this._performTokenSearch(token); }, /** * The key press listener for the search container. */ - _onKeyPress: function DVF__onScriptsKeyPress(e) { + _onKeyPress: function(e) { // This attribute is not implemented in Gecko at this time, see bug 680830. e.char = String.fromCharCode(e.charCode); let [operator, file, line, token] = this.searchboxInfo; let isGlobal = operator == SEARCH_GLOBAL_FLAG; let isFunction = operator == SEARCH_FUNCTION_FLAG; let isVariable = operator == SEARCH_VARIABLE_FLAG; let action = -1; @@ -1170,89 +1168,89 @@ FilterView.prototype = { if (offset > -1) { editor.setSelection(offset, offset + token.length) } }, /** * The blur listener for the search container. */ - _onBlur: function DVF__onBlur() { + _onBlur: function() { DebuggerView.GlobalSearch.clearView(); DebuggerView.FilteredSources.clearView(); DebuggerView.FilteredFunctions.clearView(); DebuggerView.Variables.performSearch(null); this._searchboxHelpPanel.hidePopup(); }, /** * Called when a filtering key sequence was pressed. * * @param string aOperator * The operator to use for filtering. */ - _doSearch: function DVF__doSearch(aOperator = "") { + _doSearch: function(aOperator = "") { this._searchbox.focus(); this._searchbox.value = ""; // Need to clear value beforehand. Bug 779738. this._searchbox.value = aOperator; }, /** * Called when the source location filter key sequence was pressed. */ - _doFileSearch: function DVF__doFileSearch() { + _doFileSearch: function() { this._doSearch(); this._searchboxHelpPanel.openPopup(this._searchbox); }, /** * Called when the global search filter key sequence was pressed. */ - _doGlobalSearch: function DVF__doGlobalSearch() { + _doGlobalSearch: function() { this._doSearch(SEARCH_GLOBAL_FLAG); this._searchboxHelpPanel.hidePopup(); }, /** * Called when the source function filter key sequence was pressed. */ - _doFunctionSearch: function DVF__doFunctionSearch() { + _doFunctionSearch: function() { this._doSearch(SEARCH_FUNCTION_FLAG); this._searchboxHelpPanel.hidePopup(); }, /** * Called when the source token filter key sequence was pressed. */ - _doTokenSearch: function DVF__doTokenSearch() { + _doTokenSearch: function() { this._doSearch(SEARCH_TOKEN_FLAG); this._searchboxHelpPanel.hidePopup(); }, /** * Called when the source line filter key sequence was pressed. */ - _doLineSearch: function DVF__doLineSearch() { + _doLineSearch: function() { this._doSearch(SEARCH_LINE_FLAG); this._searchboxHelpPanel.hidePopup(); }, /** * Called when the variable search filter key sequence was pressed. */ - _doVariableSearch: function DVF__doVariableSearch() { + _doVariableSearch: function() { DebuggerView.Variables.performSearch(""); this._doSearch(SEARCH_VARIABLE_FLAG); this._searchboxHelpPanel.hidePopup(); }, /** * Called when the variables focus key sequence was pressed. */ - _doVariablesFocus: function DVG__doVariablesFocus() { + _doVariablesFocus: function() { DebuggerView.showInstrumentsPane(); DebuggerView.Variables.focusFirstVisibleNode(); }, _searchbox: null, _searchboxHelpPanel: null, _globalOperatorButton: null, _globalOperatorLabel: null, @@ -1286,35 +1284,35 @@ function FilteredSourcesView() { this.onClick = this.onClick.bind(this); this.onSelect = this.onSelect.bind(this); } create({ constructor: FilteredSourcesView, proto: ResultsPanelContainer.prototype }, { /** * Initialization function, called when the debugger is started. */ - initialize: function DVFS_initialize() { + initialize: function() { dumpn("Initializing the FilteredSourcesView"); this.anchor = document.getElementById("searchbox"); }, /** * Destruction function, called when the debugger is closed. */ - destroy: function DVFS_destroy() { + destroy: function() { dumpn("Destroying the FilteredSourcesView"); this.anchor = null; }, /** * Updates the list of sources displayed in this container. */ - syncFileSearch: function DVFS_syncFileSearch() { + syncFileSearch: function() { this.empty(); // If there's no currently searched file, or there are no matches found, // hide the popup and avoid creating the view again. if (!DebuggerView.Filtering.searchedFile || !DebuggerView.Sources.visibleItems.length) { this.hidden = true; return; @@ -1342,31 +1340,31 @@ create({ constructor: FilteredSourcesVie // Only display the results panel if there's at least one entry available. this.hidden = this.itemCount == 0; }, /** * The click listener for this container. */ - onClick: function DVFS_onClick(e) { + onClick: function(e) { let locationItem = this.getItemForElement(e.target); if (locationItem) { this.select(locationItem); DebuggerView.Filtering.clearSearch(); } }, /** * The select listener for this container. * * @param MenuItem aItem * The item associated with the element to select. */ - onSelect: function DVFS_onSelect(e) { + onSelect: function(e) { let locationItem = this.getItemForElement(e.target); if (locationItem) { DebuggerView.Sources.selectedValue = locationItem.attachment.fullValue; } } }); /** @@ -1380,43 +1378,43 @@ function FilteredFunctionsView() { this.onClick = this.onClick.bind(this); this.onSelect = this.onSelect.bind(this); } create({ constructor: FilteredFunctionsView, proto: ResultsPanelContainer.prototype }, { /** * Initialization function, called when the debugger is started. */ - initialize: function DVFF_initialize() { + initialize: function() { dumpn("Initializing the FilteredFunctionsView"); this.anchor = document.getElementById("searchbox"); }, /** * Destruction function, called when the debugger is closed. */ - destroy: function DVFF_destroy() { + destroy: function() { dumpn("Destroying the FilteredFunctionsView"); this.anchor = null; }, /** * Allows searches to be scheduled and delayed to avoid redundant calls. */ delayedSearch: true, /** * Schedules searching for a function in all of the sources. * * @param string aQuery * The function to search for. */ - scheduleSearch: function DVFF_scheduleSearch(aQuery) { + scheduleSearch: function(aQuery) { if (!this.delayedSearch) { this.performSearch(aQuery); return; } let delay = Math.max(FUNCTION_SEARCH_ACTION_MAX_DELAY / aQuery.length, 0); window.clearTimeout(this._searchTimeout); this._searchFunction = this._startSearch.bind(this, aQuery); @@ -1424,41 +1422,41 @@ create({ constructor: FilteredFunctionsV }, /** * Immediately searches for a function in all of the sources. * * @param string aQuery * The function to search for. */ - performSearch: function DVFF_performSearch(aQuery) { + performSearch: function(aQuery) { window.clearTimeout(this._searchTimeout); this._searchFunction = null; this._startSearch(aQuery); }, /** * Starts searching for a function in all of the sources. * * @param string aQuery * The function to search for. */ - _startSearch: function DVFF__startSearch(aQuery) { + _startSearch: function(aQuery) { this._searchedToken = aQuery; DebuggerController.SourceScripts.fetchSources(DebuggerView.Sources.values, { onFinished: this._performFunctionSearch }); }, /** * Finds function matches in all the sources stored in the cache, and groups * them by location and line number. */ - _performFunctionSearch: function DVFF__performFunctionSearch() { + _performFunctionSearch: function() { // Get the currently searched token from the filtering input. // Continue parsing even if the searched token is an empty string, to // cache the syntax tree nodes generated by the reflection API. let token = this._searchedToken; // Make sure the currently displayed source is parsed first. Once the // maximum allowed number of resutls are found, parsing will be halted. let sourcesCache = DebuggerController.SourceScripts.getCache(); @@ -1504,17 +1502,17 @@ create({ constructor: FilteredFunctionsV }, /** * Updates the list of functions displayed in this container. * * @param array aSearchResults * The results array, containing search details for each source. */ - _syncFunctionSearch: function DVFF__syncFunctionSearch(aSearchResults) { + _syncFunctionSearch: function(aSearchResults) { this.empty(); // Show the popup even if the search token is an empty string. If there are // no matches found, hide the popup and avoid creating the view again. if (!aSearchResults.length) { this.hidden = true; return; } @@ -1560,28 +1558,28 @@ create({ constructor: FilteredFunctionsV // Select the first entry in this container. this.select(0); this.hidden = this.itemCount == 0; }, /** * The click listener for this container. */ - onClick: function DVFF_onClick(e) { + onClick: function(e) { let functionItem = this.getItemForElement(e.target); if (functionItem) { this.select(functionItem); DebuggerView.Filtering.clearSearch(); } }, /** * The select listener for this container. */ - onSelect: function DVFF_onSelect(e) { + onSelect: function(e) { let functionItem = this.getItemForElement(e.target); if (functionItem) { let sourceUrl = functionItem.attachment.sourceUrl; let scriptOffset = functionItem.attachment.scriptOffset; let actualLocation = functionItem.attachment.actualLocation; DebuggerView.updateEditor(sourceUrl, actualLocation.start.line, { charOffset: scriptOffset,
--- a/browser/devtools/debugger/debugger-view.js +++ b/browser/devtools/debugger/debugger-view.js @@ -33,17 +33,17 @@ const SEARCH_VARIABLE_FLAG = "*"; */ let DebuggerView = { /** * Initializes the debugger view. * * @param function aCallback * Called after the view finishes initializing. */ - initialize: function DV_initialize(aCallback) { + initialize: function(aCallback) { dumpn("Initializing the DebuggerView"); this._initializeWindow(); this._initializePanes(); this.Toolbar.initialize(); this.Options.initialize(); this.Filtering.initialize(); @@ -67,17 +67,17 @@ let DebuggerView = { }, /** * Destroys the debugger view. * * @param function aCallback * Called after the view finishes destroying. */ - destroy: function DV_destroy(aCallback) { + destroy: function(aCallback) { dumpn("Destroying the DebuggerView"); this.Toolbar.destroy(); this.Options.destroy(); this.Filtering.destroy(); this.FilteredSources.destroy(); this.FilteredFunctions.destroy(); this.ChromeGlobals.destroy(); @@ -90,17 +90,17 @@ let DebuggerView = { this._destroyPanes(); this._destroyEditor(); aCallback(); }, /** * Initializes the UI for the window. */ - _initializeWindow: function DV__initializeWindow() { + _initializeWindow: function() { dumpn("Initializing the DebuggerView window"); let isRemote = window._isRemoteDebugger; let isChrome = window._isChromeDebugger; if (isRemote || isChrome) { window.moveTo(Prefs.windowX, Prefs.windowY); window.resizeTo(Prefs.windowWidth, Prefs.windowHeight); @@ -111,31 +111,31 @@ let DebuggerView = { document.title = L10N.getStr("chromeDebuggerWindowTitle"); } } }, /** * Destroys the UI for the window. */ - _destroyWindow: function DV__destroyWindow() { + _destroyWindow: function() { dumpn("Destroying the DebuggerView window"); if (window._isRemoteDebugger || window._isChromeDebugger) { Prefs.windowX = window.screenX; Prefs.windowY = window.screenY; Prefs.windowWidth = window.outerWidth; Prefs.windowHeight = window.outerHeight; } }, /** * Initializes the UI for all the displayed panes. */ - _initializePanes: function DV__initializePanes() { + _initializePanes: function() { dumpn("Initializing the DebuggerView panes"); this._sourcesPane = document.getElementById("sources-pane"); this._instrumentsPane = document.getElementById("instruments-pane"); this._instrumentsPaneToggleButton = document.getElementById("instruments-pane-toggle"); this._collapsePaneString = L10N.getStr("collapsePanes"); this._expandPaneString = L10N.getStr("expandPanes"); @@ -143,70 +143,70 @@ let DebuggerView = { this._sourcesPane.setAttribute("width", Prefs.sourcesWidth); this._instrumentsPane.setAttribute("width", Prefs.instrumentsWidth); this.toggleInstrumentsPane({ visible: Prefs.panesVisibleOnStartup }); }, /** * Destroys the UI for all the displayed panes. */ - _destroyPanes: function DV__destroyPanes() { + _destroyPanes: function() { dumpn("Destroying the DebuggerView panes"); Prefs.sourcesWidth = this._sourcesPane.getAttribute("width"); Prefs.instrumentsWidth = this._instrumentsPane.getAttribute("width"); this._sourcesPane = null; this._instrumentsPane = null; this._instrumentsPaneToggleButton = null; }, /** * Initializes the SourceEditor instance. * * @param function aCallback * Called after the editor finishes initializing. */ - _initializeEditor: function DV__initializeEditor(aCallback) { + _initializeEditor: function(aCallback) { dumpn("Initializing the DebuggerView editor"); let placeholder = document.getElementById("editor"); let config = { mode: SourceEditor.MODES.JAVASCRIPT, readOnly: true, showLineNumbers: true, showAnnotationRuler: true, showOverviewRuler: true }; this.editor = new SourceEditor(); - this.editor.init(placeholder, config, function() { + this.editor.init(placeholder, config, () => { this._loadingText = L10N.getStr("loadingText"); this._onEditorLoad(); aCallback(); - }.bind(this)); + }); }, /** * The load event handler for the source editor, also executing any necessary * post-load operations. */ - _onEditorLoad: function DV__onEditorLoad() { + _onEditorLoad: function() { dumpn("Finished loading the DebuggerView editor"); DebuggerController.Breakpoints.initialize(); window.dispatchEvent(document, "Debugger:EditorLoaded", this.editor); this.editor.focus(); }, /** * Destroys the SourceEditor instance and also executes any necessary * post-unload operations. */ - _destroyEditor: function DV__destroyEditor() { + _destroyEditor: function() { dumpn("Destroying the DebuggerView editor"); DebuggerController.Breakpoints.destroy(); window.dispatchEvent(document, "Debugger:EditorUnloaded", this.editor); }, /** * Sets the proper editor mode (JS or HTML) according to the specified @@ -214,17 +214,17 @@ let DebuggerView = { * * @param string aUrl * The source url. * @param string aContentType [optional] * The source content type. * @param string aTextContent [optional] * The source text content. */ - setEditorMode: function DV_setEditorMode(aUrl, aContentType = "", aTextContent = "") { + setEditorMode: function(aUrl, aContentType = "", aTextContent = "") { if (aContentType) { if (/javascript/.test(aContentType)) { this.editor.setMode(SourceEditor.MODES.JAVASCRIPT); } else { this.editor.setMode(SourceEditor.MODES.HTML); } } else if (aTextContent.match(/^\s*</)) { // Use HTML mode for files in which the first non whitespace character is @@ -323,17 +323,17 @@ let DebuggerView = { * Additional options for showing the source. Supported options: * - charOffset: character offset for the caret or debug location * - lineOffset: line offset for the caret or debug location * - columnOffset: column offset for the caret or debug location * - noSwitch: don't switch to the source if not currently selected * - noCaret: don't set the caret location at the specified line * - noDebug: don't set the debug location at the specified line */ - updateEditor: function DV_updateEditor(aUrl, aLine, aFlags = {}) { + updateEditor: function(aUrl, aLine, aFlags = {}) { if (!this._isInitialized || this._isDestroyed) { return; } // If the location is not specified, default to the location given by // the currently active frame in the stack. if (!aUrl && !aLine) { let cachedFrames = DebuggerController.activeThread.cachedFrames; let currentFrame = DebuggerController.StackFrames.currentFrame; @@ -387,30 +387,30 @@ let DebuggerView = { * Gets the text in the source editor's specified line. * * @param number aLine [optional] * The line to get the text from. * If unspecified, it defaults to the current caret position line. * @return string * The specified line's text. */ - getEditorLine: function DV_getEditorLine(aLine) { + getEditorLine: function(aLine) { let line = aLine || this.editor.getCaretPosition().line; let start = this.editor.getLineStart(line); let end = this.editor.getLineEnd(line); return this.editor.getText(start, end); }, /** * Gets the text in the source editor's selection bounds. * * @return string * The selected text. */ - getEditorSelection: function DV_getEditorSelection() { + getEditorSelection: function() { let selection = this.editor.getSelection(); return this.editor.getText(selection.start, selection.end); }, /** * Gets the visibility state of the instruments pane. * @return boolean */ @@ -422,17 +422,17 @@ let DebuggerView = { * * @param object aFlags * An object containing some of the following properties: * - visible: true if the pane should be shown, false to hide * - animated: true to display an animation on toggle * - delayed: true to wait a few cycles before toggle * - callback: a function to invoke when the toggle finishes */ - toggleInstrumentsPane: function DV__toggleInstrumentsPane(aFlags) { + toggleInstrumentsPane: function(aFlags) { let pane = this._instrumentsPane; let button = this._instrumentsPaneToggleButton; ViewHelpers.togglePane(aFlags, pane); if (aFlags.visible) { button.removeAttribute("pane-collapsed"); button.setAttribute("tooltiptext", this._collapsePaneString); @@ -443,29 +443,29 @@ let DebuggerView = { }, /** * Sets the instruments pane visible after a short period of time. * * @param function aCallback * A function to invoke when the toggle finishes. */ - showInstrumentsPane: function DV__showInstrumentsPane(aCallback) { + showInstrumentsPane: function(aCallback) { DebuggerView.toggleInstrumentsPane({ visible: true, animated: true, delayed: true, callback: aCallback }); }, /** * Handles any initialization on a tab navigation event issued by the client. */ - _handleTabNavigation: function DV__handleTabNavigation() { + _handleTabNavigation: function() { dumpn("Handling tab navigation in the DebuggerView"); this.Filtering.clearSearch(); this.FilteredSources.clearView(); this.FilteredFunctions.clearView(); this.GlobalSearch.clearView(); this.ChromeGlobals.empty(); this.StackFrames.empty(); @@ -560,18 +560,17 @@ ListWidget.prototype = { * The actual internal value of the item. * @param string aDescription [optional] * An optional description of the item. * @param any aAttachment [optional] * Some attached primitive/object. * @return nsIDOMNode * The element associated with the displayed item. */ - insertItemAt: - function DVSL_insertItemAt(aIndex, aLabel, aValue, aDescription, aAttachment) { + insertItemAt: function(aIndex, aLabel, aValue, aDescription, aAttachment) { let list = this._list; let childNodes = list.childNodes; let element = document.createElement(this.itemType); this.itemFactory(element, aAttachment, aLabel, aValue, aDescription); this._removeEmptyNotice(); element.classList.add("list-widget-item"); @@ -581,41 +580,41 @@ ListWidget.prototype = { /** * Returns the child node in this container situated at the specified index. * * @param number aIndex * The position in the container intended for this item. * @return nsIDOMNode * The element associated with the displayed item. */ - getItemAtIndex: function DVSL_getItemAtIndex(aIndex) { + getItemAtIndex: function(aIndex) { return this._list.childNodes[aIndex]; }, /** * Immediately removes the specified child node from this container. * * @param nsIDOMNode aChild * The element associated with the displayed item. */ - removeChild: function DVSL__removeChild(aChild) { + removeChild: function(aChild) { this._list.removeChild(aChild); if (this._selectedItem == aChild) { this._selectedItem = null; } if (!this._list.hasChildNodes()) { this._appendEmptyNotice(); } }, /** * Immediately removes all of the child nodes from this container. */ - removeAllItems: function DVSL_removeAllItems() { + removeAllItems: function() { let parent = this._parent; let list = this._list; let firstChild; while ((firstChild = list.firstChild)) { list.removeChild(firstChild); } parent.scrollTop = 0; @@ -673,49 +672,49 @@ ListWidget.prototype = { } this._emptyTextValue = aValue; this._appendEmptyNotice(); }, /** * Creates and appends a label displayed permanently in this container's header. */ - _appendPermaNotice: function DVSL__appendPermaNotice() { + _appendPermaNotice: function() { if (this._permaTextNode || !this._permaTextValue) { return; } let label = document.createElement("label"); label.className = "empty list-widget-item"; label.setAttribute("value", this._permaTextValue); this._parent.insertBefore(label, this._list); this._permaTextNode = label; }, /** * Creates and appends a label signaling that this container is empty. */ - _appendEmptyNotice: function DVSL__appendEmptyNotice() { + _appendEmptyNotice: function() { if (this._emptyTextNode || !this._emptyTextValue) { return; } let label = document.createElement("label"); label.className = "empty list-widget-item"; label.setAttribute("value", this._emptyTextValue); this._parent.appendChild(label); this._emptyTextNode = label; }, /** * Removes the label signaling that this container is empty. */ - _removeEmptyNotice: function DVSL__removeEmptyNotice() { + _removeEmptyNotice: function() { if (!this._emptyTextNode) { return; } this._parent.removeChild(this._emptyTextNode); this._emptyTextNode = null; }, @@ -822,51 +821,51 @@ create({ constructor: ResultsPanelContai */ get hidden() this._panel.state == "closed" || this._panel.state == "hiding", /** * Removes all items from this container and hides it. */ - clearView: function RPC_clearView() { + clearView: function() { this.hidden = true; this.empty(); window.dispatchEvent(document, "Debugger:ResultsPanelContainer:ViewCleared"); }, /** * Focuses the next found item in this container. */ - focusNext: function RPC_focusNext() { + focusNext: function() { let nextIndex = this.selectedIndex + 1; if (nextIndex >= this.itemCount) { nextIndex = 0; } this.select(this.getItemAtIndex(nextIndex)); }, /** * Focuses the previously found item in this container. */ - focusPrev: function RPC_focusPrev() { + focusPrev: function() { let prevIndex = this.selectedIndex - 1; if (prevIndex < 0) { prevIndex = this.itemCount - 1; } this.select(this.getItemAtIndex(prevIndex)); }, /** * Updates the selected item in this container. * * @param MenuItem | number aItem * The item associated with the element to select. */ - select: function RPC_select(aItem) { + select: function(aItem) { if (typeof aItem == "number") { this.select(this.getItemAtIndex(aItem)); return; } // Update the currently selected item in this container using the // selectedItem setter in the MenuContainer prototype chain. this.selectedItem = aItem; @@ -933,17 +932,17 @@ function RemoteDebuggerPrompt() { RemoteDebuggerPrompt.prototype = { /** * Shows the prompt and waits for a remote host and port to connect to. * * @param boolean aIsReconnectingFlag * True to show the reconnect message instead of the connect request. */ - show: function RDP_show(aIsReconnectingFlag) { + show: function(aIsReconnectingFlag) { let check = { value: Prefs.remoteAutoConnect }; let input = { value: Prefs.remoteHost + ":" + Prefs.remotePort }; let parts; while (true) { let result = Services.prompt.prompt(null, L10N.getStr("remoteDebuggerPromptTitle"), L10N.getStr(aIsReconnectingFlag
--- a/browser/devtools/debugger/test/head.js +++ b/browser/devtools/debugger/test/head.js @@ -7,16 +7,17 @@ const Ci = Components.interfaces; const Cu = Components.utils; let tempScope = {}; Cu.import("resource://gre/modules/Services.jsm", tempScope); Cu.import("resource://gre/modules/devtools/dbg-server.jsm", tempScope); Cu.import("resource://gre/modules/devtools/dbg-client.jsm", tempScope); Cu.import("resource:///modules/source-editor.jsm", tempScope); Cu.import("resource:///modules/devtools/gDevTools.jsm", tempScope); +Cu.import("resource://gre/modules/devtools/Loader.jsm", tempScope); let Services = tempScope.Services; let SourceEditor = tempScope.SourceEditor; let DebuggerServer = tempScope.DebuggerServer; let DebuggerTransport = tempScope.DebuggerTransport; let DebuggerClient = tempScope.DebuggerClient; let gDevTools = tempScope.gDevTools; let devtools = tempScope.devtools; let TargetFactory = devtools.TargetFactory;
--- a/browser/devtools/debugger/test/helpers.js +++ b/browser/devtools/debugger/test/helpers.js @@ -19,17 +19,17 @@ this.EXPORTED_SYMBOLS = [ 'helpers' ]; var helpers = {}; this.helpers = helpers; let require = (Cu.import("resource://gre/modules/devtools/Require.jsm", {})).require; Components.utils.import("resource://gre/modules/devtools/gcli.jsm", {}); let console = (Cu.import("resource://gre/modules/devtools/Console.jsm", {})).console; -let TargetFactory = (Cu.import("resource:///modules/devtools/gDevTools.jsm", {})).devtools.TargetFactory; +let TargetFactory = (Cu.import("resource://gre/modules/devtools/Loader.jsm", {})).devtools.TargetFactory; let Promise = (Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", {})).Promise; let assert = { ok: ok, is: is, log: info }; var util = require('util/util'); var converters = require('gcli/converters');
--- a/browser/devtools/fontinspector/test/browser_fontinspector.js +++ b/browser/devtools/fontinspector/test/browser_fontinspector.js @@ -1,13 +1,14 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ let tempScope = {}; -let {devtools, gDevTools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {}); +let {gDevTools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {}); +let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); let TargetFactory = devtools.TargetFactory; let DOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils); function test() { waitForExplicitFinish(); let doc;
--- a/browser/devtools/framework/connect/connect.js +++ b/browser/devtools/framework/connect/connect.js @@ -5,17 +5,18 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; const Cu = Components.utils; Cu.import('resource://gre/modules/XPCOMUtils.jsm'); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/devtools/dbg-client.jsm"); -let {devtools, gDevTools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {}); +let {gDevTools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {}); +let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); let gClient; let gConnectionTimeout; XPCOMUtils.defineLazyGetter(window, 'l10n', function () { return Services.strings.createBundle('chrome://browser/locale/devtools/connection-screen.properties'); });
--- a/browser/devtools/framework/gDevTools.jsm +++ b/browser/devtools/framework/gDevTools.jsm @@ -1,200 +1,23 @@ /* 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"; -this.EXPORTED_SYMBOLS = [ "gDevTools", "DevTools", "gDevToolsBrowser", "devtools" ]; +this.EXPORTED_SYMBOLS = [ "gDevTools", "DevTools", "gDevToolsBrowser" ]; const { classes: Cc, interfaces: Ci, utils: Cu } = Components; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource:///modules/devtools/shared/event-emitter.js"); -Cu.import("resource://gre/modules/FileUtils.jsm"); -Cu.import("resource://gre/modules/NetUtil.jsm"); Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js"); - -XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm"); - -let loader = Cu.import("resource://gre/modules/commonjs/toolkit/loader.js", {}).Loader; - -// Used when the tools should be loaded from the Firefox package itself (the default) - -var BuiltinProvider = { - load: function(done) { - this.loader = new loader.Loader({ - paths: { - "": "resource://gre/modules/commonjs/", - "main" : "resource:///modules/devtools/main", - "devtools": "resource:///modules/devtools", - "devtools/toolkit": "resource://gre/modules/devtools" - }, - globals: {}, - }); - this.main = loader.main(this.loader, "main"); - - return Promise.resolve(undefined); - }, - - unload: function(reason) { - loader.unload(this.loader, reason); - delete this.loader; - }, -}; - -var SrcdirProvider = { - load: function(done) { - let srcdir = Services.prefs.getComplexValue("devtools.loader.srcdir", - Ci.nsISupportsString); - srcdir = OS.Path.normalize(srcdir.data.trim()); - let devtoolsDir = OS.Path.join(srcdir, "browser/devtools"); - let toolkitDir = OS.Path.join(srcdir, "toolkit/devtools"); - - this.loader = new loader.Loader({ - paths: { - "": "resource://gre/modules/commonjs/", - "devtools/toolkit": "file://" + toolkitDir, - "devtools": "file://" + devtoolsDir, - "main": "file://" + devtoolsDir + "/main.js" - }, - globals: {} - }); - - this.main = loader.main(this.loader, "main"); - - return this._writeManifest(devtoolsDir).then((data) => { - this._writeManifest(toolkitDir); - }).then(null, Cu.reportError); - }, - - unload: function(reason) { - loader.unload(this.loader, reason); - delete this.loader; - }, - - _readFile: function(filename) { - let deferred = Promise.defer(); - let file = new FileUtils.File(filename); - NetUtil.asyncFetch(file, (inputStream, status) => { - if (!Components.isSuccessCode(status)) { - deferred.reject(new Error("Couldn't load manifest: " + filename + "\n")); - return; - } - var data = NetUtil.readInputStreamToString(inputStream, inputStream.available()); - deferred.resolve(data); - }); - return deferred.promise; - }, - - _writeFile: function(filename, data) { - let deferred = Promise.defer(); - let file = new FileUtils.File(filename); - - var ostream = FileUtils.openSafeFileOutputStream(file) - - var converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]. - createInstance(Ci.nsIScriptableUnicodeConverter); - converter.charset = "UTF-8"; - var istream = converter.convertToInputStream(data); - NetUtil.asyncCopy(istream, ostream, (status) => { - if (!Components.isSuccessCode(status)) { - deferred.reject(new Error("Couldn't write manifest: " + filename + "\n")); - return; - } - - deferred.resolve(null); - }); - return deferred.promise; - }, - - _writeManifest: function(dir) { - return this._readFile(dir + "/jar.mn").then((data) => { - // The file data is contained within inputStream. - // You can read it into a string with - let entries = []; - let lines = data.split(/\n/); - let preprocessed = /^\s*\*/; - let contentEntry = new RegExp("^\\s+content/(\\w+)/(\\S+)\\s+\\((\\S+)\\)"); - for (let line of lines) { - if (preprocessed.test(line)) { - dump("Unable to override preprocessed file: " + line + "\n"); - continue; - } - let match = contentEntry.exec(line); - if (match) { - let entry = "override chrome://" + match[1] + "/content/" + match[2] + "\tfile://" + dir + "/" + match[3]; - entries.push(entry); - } - } - return this._writeFile(dir + "/chrome.manifest", entries.join("\n")); - }).then(() => { - Components.manager.addBootstrappedManifestLocation(new FileUtils.File(dir)); - }); - } -}; - -this.devtools = { - _provider: null, - - get main() this._provider.main, - - // This is a gross gross hack. In one place (computed-view.js) we use - // Iterator, but the addon-sdk loader takes Iterator off the global. - // Give computed-view.js a way to get back to the Iterator until we have - // a chance to fix that crap. - _Iterator: Iterator, - - setProvider: function(provider) { - if (provider === this._provider) { - return; - } - - if (this._provider) { - delete this.require; - this._provider.unload("newprovider"); - gDevTools._teardown(); - } - this._provider = provider; - this._provider.load(); - this.require = loader.Require(this._provider.loader, { id: "devtools" }) - - let exports = this._provider.main; - // Let clients find exports on this object. - Object.getOwnPropertyNames(exports).forEach(key => { - XPCOMUtils.defineLazyGetter(this, key, () => exports[key]); - }); - }, - - /** - * Choose a default tools provider based on the preferences. - */ - _chooseProvider: function() { - if (Services.prefs.prefHasUserValue("devtools.loader.srcdir")) { - this.setProvider(SrcdirProvider); - } else { - this.setProvider(BuiltinProvider); - } - }, - - /** - * Reload the current provider. - */ - reload: function() { - var events = devtools.require("sdk/system/events"); - events.emit("startupcache-invalidate", {}); - - this._provider.unload("reload"); - delete this._provider; - gDevTools._teardown(); - this._chooseProvider(); - }, -}; +Cu.import("resource://gre/modules/devtools/Loader.jsm"); const FORBIDDEN_IDS = new Set(["toolbox", ""]); const MAX_ORDINAL = 99; /** * DevTools is a class that represents a set of developer tools, it holds a * set of tools and keeps track of open toolboxes in the browser. */ @@ -871,10 +694,10 @@ gDevTools.on("tool-unregistered", functi gDevToolsBrowser._removeToolFromWindows(toolId); }); gDevTools.on("toolbox-ready", gDevToolsBrowser._updateMenuCheckbox); gDevTools.on("toolbox-destroyed", gDevToolsBrowser._updateMenuCheckbox); Services.obs.addObserver(gDevToolsBrowser.destroy, "quit-application", false); -// Now load the tools. -devtools._chooseProvider(); +// Load the browser devtools main module as the loader's main module. +devtools.main("devtools/main");
--- a/browser/devtools/framework/test/browser_toolbox_hosts.js +++ b/browser/devtools/framework/test/browser_toolbox_hosts.js @@ -1,16 +1,19 @@ /* vim: set ts=2 et sw=2 tw=80: */ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ let temp = {} Cu.import("resource:///modules/devtools/gDevTools.jsm", temp); let DevTools = temp.DevTools; +Cu.import("resource://gre/modules/devtools/Loader.jsm", temp); +let devtools = temp.devtools; + let Toolbox = devtools.Toolbox; let toolbox, target; function test() { waitForExplicitFinish();
--- a/browser/devtools/framework/test/head.js +++ b/browser/devtools/framework/test/head.js @@ -5,17 +5,17 @@ let TargetFactory = gDevTools.TargetFactory; let tempScope = {}; Components.utils.import("resource://gre/modules/devtools/Console.jsm", tempScope); let console = tempScope.console; Components.utils.import("resource://gre/modules/commonjs/sdk/core/promise.js", tempScope); let Promise = tempScope.Promise; -let {devtools} = Components.utils.import("resource:///modules/devtools/gDevTools.jsm", {}); +let {devtools} = Components.utils.import("resource://gre/modules/devtools/Loader.jsm", {}); let TargetFactory = devtools.TargetFactory; /** * Open a new tab at a URL and call a callback on load */ function addTab(aURL, aCallback) { waitForExplicitFinish();
--- a/browser/devtools/inspector/CmdInspect.jsm +++ b/browser/devtools/inspector/CmdInspect.jsm @@ -6,17 +6,17 @@ const { classes: Cc, interfaces: Ci, uti this.EXPORTED_SYMBOLS = [ ]; Cu.import("resource://gre/modules/devtools/gcli.jsm"); Cu.import('resource://gre/modules/XPCOMUtils.jsm'); XPCOMUtils.defineLazyModuleGetter(this, "gDevTools", "resource:///modules/devtools/gDevTools.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "devtools", - "resource:///modules/devtools/gDevTools.jsm"); + "resource://gre/modules/devtools/Loader.jsm"); /** * 'inspect' command */ gcli.addCommand({ name: "inspect", description: gcli.lookup("inspectDesc"), manual: gcli.lookup("inspectManual"),
--- a/browser/devtools/inspector/test/head.js +++ b/browser/devtools/inspector/test/head.js @@ -4,17 +4,17 @@ const Cu = Components.utils; const Ci = Components.interfaces; const Cc = Components.classes; let tempScope = {}; Cu.import("resource:///modules/devtools/LayoutHelpers.jsm", tempScope); let LayoutHelpers = tempScope.LayoutHelpers; -let {devtools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", tempScope); +let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", tempScope); let TargetFactory = devtools.TargetFactory; Components.utils.import("resource://gre/modules/devtools/Console.jsm", tempScope); let console = tempScope.console; // Import the GCLI test helper let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/")); Services.scriptloader.loadSubScript(testDir + "/helpers.js", this);
--- a/browser/devtools/inspector/test/helpers.js +++ b/browser/devtools/inspector/test/helpers.js @@ -19,17 +19,17 @@ this.EXPORTED_SYMBOLS = [ 'helpers' ]; var helpers = {}; this.helpers = helpers; let require = (Cu.import("resource://gre/modules/devtools/Require.jsm", {})).require; Components.utils.import("resource://gre/modules/devtools/gcli.jsm", {}); let console = (Cu.import("resource://gre/modules/devtools/Console.jsm", {})).console; -let TargetFactory = (Cu.import("resource:///modules/devtools/gDevTools.jsm", {})).devtools.TargetFactory; +let TargetFactory = (Cu.import("resource://gre/modules/devtools/Loader.jsm", {})).devtools.TargetFactory; let Promise = (Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", {})).Promise; let assert = { ok: ok, is: is, log: info }; var util = require('util/util'); var converters = require('gcli/converters');
--- a/browser/devtools/layoutview/test/browser_layoutview.js +++ b/browser/devtools/layoutview/test/browser_layoutview.js @@ -1,12 +1,12 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -let {devtools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {}); +let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); let TargetFactory = devtools.TargetFactory; function test() { waitForExplicitFinish(); Services.prefs.setBoolPref("devtools.layoutview.enabled", true); Services.prefs.setBoolPref("devtools.inspector.sidebarOpen", true);
--- a/browser/devtools/layoutview/view.js +++ b/browser/devtools/layoutview/view.js @@ -4,17 +4,17 @@ * 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 Cu = Components.utils; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource:///modules/devtools/LayoutHelpers.jsm"); -Cu.import("resource:///modules/devtools/gDevTools.jsm"); +Cu.import("resource://gre/modules/devtools/Loader.jsm"); let {CssLogic} = devtools.require("devtools/styleinspector/css-logic"); function LayoutView(aInspector, aWindow) { this.inspector = aInspector; // <browser> is not always available (for Chrome targets for example)
--- a/browser/devtools/markupview/test/head.js +++ b/browser/devtools/markupview/test/head.js @@ -1,15 +1,15 @@ /* 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/. */ const Cu = Components.utils; -let {devtools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {}); +let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); let TargetFactory = devtools.TargetFactory; // Clear preferences that may be set during the course of tests. function clearUserPrefs() { Services.prefs.clearUserPref("devtools.inspector.htmlPanelOpen"); Services.prefs.clearUserPref("devtools.inspector.sidebarOpen"); Services.prefs.clearUserPref("devtools.inspector.activeSidebar");
--- a/browser/devtools/netmonitor/NetMonitorPanel.jsm +++ b/browser/devtools/netmonitor/NetMonitorPanel.jsm @@ -10,17 +10,17 @@ const { classes: Cc, interfaces: Ci, uti this.EXPORTED_SYMBOLS = ["NetMonitorPanel"]; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource:///modules/devtools/shared/event-emitter.js"); XPCOMUtils.defineLazyModuleGetter(this, "Promise", "resource://gre/modules/commonjs/sdk/core/promise.js"); -function NetMonitorPanel(iframeWindow, toolbox) { +this.NetMonitorPanel = function NetMonitorPanel(iframeWindow, toolbox) { this.panelWin = iframeWindow; this._toolbox = toolbox; this._view = this.panelWin.NetMonitorView; this._controller = this.panelWin.NetMonitorController; this._controller._target = this.target; EventEmitter.decorate(this); @@ -28,17 +28,17 @@ function NetMonitorPanel(iframeWindow, t NetMonitorPanel.prototype = { /** * Open is effectively an asynchronous constructor. * * @return object * A Promise that is resolved when the NetMonitor completes opening. */ - open: function NetMonitorPanel_open() { + open: function() { let promise; // Local monitoring needs to make the target remote. if (!this.target.isRemote) { promise = this.target.makeRemote(); } else { promise = Promise.resolve(this.target); }
--- a/browser/devtools/netmonitor/netmonitor-controller.js +++ b/browser/devtools/netmonitor/netmonitor-controller.js @@ -1,18 +1,16 @@ /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ft=javascript ts=2 et sw=2 tw=80: */ /* 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 Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; +const { classes: Cc, interfaces: Ci, utils: Cu } = Components; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js"); Cu.import("resource:///modules/source-editor.jsm"); Cu.import("resource:///modules/devtools/shared/event-emitter.js"); Cu.import("resource:///modules/devtools/SideMenuWidget.jsm"); Cu.import("resource:///modules/devtools/VariablesView.jsm"); @@ -242,17 +240,17 @@ TargetEventsHandler.prototype = { * @param string aType * Packet type. * @param object aPacket * Packet received from the server. */ _onTabNavigated: function(aType, aPacket) { if (aType == "will-navigate") { NetMonitorView.RequestsMenu.reset(); - NetMonitorView.NetworkDetails.toggle(false); + NetMonitorView.NetworkDetails.reset(); window.emit("NetMonitor:TargetWillNavigate"); } if (aType == "navigate") { window.emit("NetMonitor:TargetNavigate"); } }, /** @@ -456,17 +454,17 @@ NetworkEventsHandler.prototype = { }, /** * Handles additional information received for a "eventTimings" packet. * * @param object aResponse * The message received from the server. */ - _onEventTimings: function NEH__onEventTimings(aResponse) { + _onEventTimings: function(aResponse) { NetMonitorView.RequestsMenu.updateRequest(aResponse.from, { eventTimings: aResponse }); window.emit("NetMonitor:NetworkEventUpdated:EventTimings"); }, /** * Fetches the full text of a LongString. @@ -474,17 +472,17 @@ NetworkEventsHandler.prototype = { * @param object | string aStringGrip * The long string grip containing the corresponding actor. * If you pass in a plain string (by accident or because you're lazy), * then a promise of the same string is simply returned. * @return object Promise * A promise that is resolved when the full string contents * are available, or rejected if something goes wrong. */ - getString: function NEH_getString(aStringGrip) { + getString: function(aStringGrip) { // Make sure this is a long string. if (typeof aStringGrip != "object" || aStringGrip.type != "longString") { return Promise.resolve(aStringGrip); // Go home string, you're drunk. } // Fetch the long string only once. if (aStringGrip._fullText) { return aStringGrip._fullText.promise; }
--- a/browser/devtools/netmonitor/netmonitor-view.js +++ b/browser/devtools/netmonitor/netmonitor-view.js @@ -11,18 +11,19 @@ const RESIZE_REFRESH_RATE = 50; // ms const REQUESTS_REFRESH_RATE = 50; // ms const REQUESTS_HEADERS_SAFE_BOUNDS = 30; // px const REQUESTS_WATERFALL_SAFE_BOUNDS = 90; // px const REQUESTS_WATERFALL_HEADER_TICKS_MULTIPLE = 5; // ms const REQUESTS_WATERFALL_HEADER_TICKS_SPACING_MIN = 60; // px const REQUESTS_WATERFALL_BACKGROUND_TICKS_MULTIPLE = 5; // ms const REQUESTS_WATERFALL_BACKGROUND_TICKS_SCALES = 3; const REQUESTS_WATERFALL_BACKGROUND_TICKS_SPACING_MIN = 10; // px -const REQUESTS_WATERFALL_BACKGROUND_TICKS_OPACITY_MIN = 10; // byte -const REQUESTS_WATERFALL_BACKGROUND_TICKS_OPACITY_ADD = 16; // byte +const REQUESTS_WATERFALL_BACKGROUND_TICKS_COLOR_RGB = [128, 136, 144]; +const REQUESTS_WATERFALL_BACKGROUND_TICKS_OPACITY_MIN = 32; // byte +const REQUESTS_WATERFALL_BACKGROUND_TICKS_OPACITY_ADD = 32; // byte const DEFAULT_HTTP_VERSION = "HTTP/1.1"; const HEADERS_SIZE_DECIMALS = 3; const CONTENT_SIZE_DECIMALS = 2; const CONTENT_MIME_TYPE_ABBREVIATIONS = { "ecmascript": "js", "javascript": "js", "x-javascript": "js" }; @@ -61,17 +62,17 @@ const GENERIC_VARIABLES_VIEW_SETTINGS = */ let NetMonitorView = { /** * Initializes the network monitor view. * * @param function aCallback * Called after the view finishes initializing. */ - initialize: function NV_initialize(aCallback) { + initialize: function(aCallback) { dumpn("Initializing the NetMonitorView"); this._initializePanes(); this.Toolbar.initialize(); this.RequestsMenu.initialize(); this.NetworkDetails.initialize(); @@ -79,49 +80,49 @@ let NetMonitorView = { }, /** * Destroys the network monitor view. * * @param function aCallback * Called after the view finishes destroying. */ - destroy: function NV_destroy(aCallback) { + destroy: function(aCallback) { dumpn("Destroying the NetMonitorView"); this.Toolbar.destroy(); this.RequestsMenu.destroy(); this.NetworkDetails.destroy(); this._destroyPanes(); aCallback(); }, /** * Initializes the UI for all the displayed panes. */ - _initializePanes: function DV__initializePanes() { + _initializePanes: function() { dumpn("Initializing the NetMonitorView panes"); this._detailsPane = $("#details-pane"); this._detailsPaneToggleButton = $("#details-pane-toggle"); this._collapsePaneString = L10N.getStr("collapseDetailsPane"); this._expandPaneString = L10N.getStr("expandDetailsPane"); this._detailsPane.setAttribute("width", Prefs.networkDetailsWidth); this._detailsPane.setAttribute("height", Prefs.networkDetailsHeight); this.toggleDetailsPane({ visible: false }); }, /** * Destroys the UI for all the displayed panes. */ - _destroyPanes: function DV__destroyPanes() { + _destroyPanes: function() { dumpn("Destroying the NetMonitorView panes"); Prefs.networkDetailsWidth = this._detailsPane.getAttribute("width"); Prefs.networkDetailsHeight = this._detailsPane.getAttribute("height"); this._detailsPane = null; this._detailsPaneToggleButton = null; }, @@ -140,17 +141,17 @@ let NetMonitorView = { * An object containing some of the following properties: * - visible: true if the pane should be shown, false to hide * - animated: true to display an animation on toggle * - delayed: true to wait a few cycles before toggle * - callback: a function to invoke when the toggle finishes * @param number aTabIndex [optional] * The index of the intended selected tab in the details pane. */ - toggleDetailsPane: function DV__toggleDetailsPane(aFlags, aTabIndex) { + toggleDetailsPane: function(aFlags, aTabIndex) { let pane = this._detailsPane; let button = this._detailsPaneToggleButton; ViewHelpers.togglePane(aFlags, pane); if (aFlags.visible) { button.removeAttribute("pane-collapsed"); button.setAttribute("tooltiptext", this._collapsePaneString); @@ -167,17 +168,17 @@ let NetMonitorView = { /** * Lazily initializes and returns a promise for a SourceEditor instance. * * @param string aId * The id of the editor placeholder node. * @return object * A Promise that is resolved when the editor is available. */ - editor: function NV_editor(aId) { + editor: function(aId) { dumpn("Getting a NetMonitorView editor: " + aId); if (this._editorPromises.has(aId)) { return this._editorPromises.get(aId); } let deferred = Promise.defer(); this._editorPromises.set(aId, deferred.promise); @@ -204,36 +205,36 @@ function ToolbarView() { this._onTogglePanesPressed = this._onTogglePanesPressed.bind(this); } ToolbarView.prototype = { /** * Initialization function, called when the debugger is started. */ - initialize: function NVT_initialize() { + initialize: function() { dumpn("Initializing the ToolbarView"); this._detailsPaneToggleButton = $("#details-pane-toggle"); this._detailsPaneToggleButton.addEventListener("mousedown", this._onTogglePanesPressed, false); }, /** * Destruction function, called when the debugger is closed. */ - destroy: function NVT_destroy() { + destroy: function() { dumpn("Destroying the ToolbarView"); this._detailsPaneToggleButton.removeEventListener("mousedown", this._onTogglePanesPressed, false); }, /** * Listener handling the toggle button click event. */ - _onTogglePanesPressed: function NVT__onTogglePanesPressed() { + _onTogglePanesPressed: function() { let requestsMenu = NetMonitorView.RequestsMenu; let networkDetails = NetMonitorView.NetworkDetails; // Make sure there's a selection if the button is pressed, to avoid // showing an empty network details pane. if (!requestsMenu.selectedItem && requestsMenu.itemCount) { requestsMenu.selectedIndex = 0; } @@ -261,43 +262,43 @@ function RequestsMenuView() { this._onSelect = this._onSelect.bind(this); this._onResize = this._onResize.bind(this); } create({ constructor: RequestsMenuView, proto: MenuContainer.prototype }, { /** * Initialization function, called when the network monitor is started. */ - initialize: function NVRM_initialize() { + initialize: function() { dumpn("Initializing the RequestsMenuView"); this.node = new SideMenuWidget($("#requests-menu-contents"), false); this.node.maintainSelectionVisible = false; this.node.autoscrollWithAppendedItems = true; this.node.addEventListener("mousedown", this._onMouseDown, false); this.node.addEventListener("select", this._onSelect, false); window.addEventListener("resize", this._onResize, false); }, /** * Destruction function, called when the network monitor is closed. */ - destroy: function NVRM_destroy() { + destroy: function() { dumpn("Destroying the SourcesView"); this.node.removeEventListener("mousedown", this._onMouseDown, false); this.node.removeEventListener("select", this._onSelect, false); window.removeEventListener("resize", this._onResize, false); }, /** * Resets this container (removes all the networking information). */ - reset: function NVRM_reset() { + reset: function() { this.empty(); this._firstRequestStartedMillis = -1; this._lastRequestEndedMillis = -1; }, /** * Specifies if this view may be updated lazily. */ @@ -311,17 +312,17 @@ create({ constructor: RequestsMenuView, * @param string aStartedDateTime * A string representation of when the request was started, which * can be parsed by Date (for example "2012-09-17T19:50:03.699Z"). * @param string aMethod * Specifies the request method (e.g. "GET", "POST", etc.) * @param string aUrl * Specifies the request's url. */ - addRequest: function NVRM_addRequest(aId, aStartedDateTime, aMethod, aUrl) { + addRequest: function(aId, aStartedDateTime, aMethod, aUrl) { // Convert the received date/time string to a unix timestamp. let unixTime = Date.parse(aStartedDateTime); // Create the element node for the network request item. let menuView = this._createMenuView(aMethod, aUrl); // Remember the first and last event boundaries. this._registerFirstRequestStart(unixTime); @@ -346,17 +347,17 @@ create({ constructor: RequestsMenuView, }, /** * Sorts all network requests in this container by a specified detail. * * @param string aType * Either "status", "method", "file", "domain", "type" or "size". */ - sortBy: function NVRM_sortBy(aType) { + sortBy: function(aType) { let target = $("#requests-menu-" + aType + "-button"); let headers = document.querySelectorAll(".requests-menu-header-button"); for (let header of headers) { if (header != target) { header.removeAttribute("sorted"); header.removeAttribute("tooltiptext"); } @@ -470,17 +471,17 @@ create({ constructor: RequestsMenuView, * Schedules adding additional information to a network request. * * @param string aId * An identifier coming from the network monitor controller. * @param object aData * An object containing several { key: value } tuples of network info. * Supported keys are "httpVersion", "status", "statusText" etc. */ - updateRequest: function NVRM_updateRequest(aId, aData) { + updateRequest: function(aId, aData) { // Prevent interference from zombie updates received after target closed. if (NetMonitorView._isDestroyed) { return; } this._updateQueue.push([aId, aData]); // Lazy updating is disabled in some tests. if (!this.lazyUpdate) { @@ -488,17 +489,17 @@ create({ constructor: RequestsMenuView, } // Allow requests to settle down first. drain("update-requests", REQUESTS_REFRESH_RATE, () => this._flushRequests()); }, /** * Starts adding all queued additional information about network requests. */ - _flushRequests: function NVRM__flushRequests() { + _flushRequests: function() { // For each queued additional information packet, get the corresponding // request item in the view and update it based on the specified data. for (let [id, data] of this._updateQueue) { let requestItem = this._cache.get(id); if (!requestItem) { // Packet corresponds to a dead request item, target navigated. continue; } @@ -587,17 +588,17 @@ create({ constructor: RequestsMenuView, * * @param string aMethod * Specifies the request method (e.g. "GET", "POST", etc.) * @param string aUrl * Specifies the request's url. * @return nsIDOMNode * The network request view. */ - _createMenuView: function NVRM__createMenuView(aMethod, aUrl) { + _createMenuView: function(aMethod, aUrl) { let uri = Services.io.newURI(aUrl, null, null).QueryInterface(Ci.nsIURL); let name = NetworkHelper.convertToUnicode(unescape(uri.fileName)) || "/"; let query = NetworkHelper.convertToUnicode(unescape(uri.query)); let hostPort = NetworkHelper.convertToUnicode(unescape(uri.hostPort)); let template = $("#requests-menu-item-template"); let fragment = document.createDocumentFragment(); @@ -624,17 +625,17 @@ create({ constructor: RequestsMenuView, * * @param MenuItem aItem * The network request item in this container. * @param string aKey * The type of information that is to be updated. * @param any aValue * The new value to be shown. */ - _updateMenuView: function NVRM__updateMenuView(aItem, aKey, aValue) { + _updateMenuView: function(aItem, aKey, aValue) { switch (aKey) { case "status": { let node = $(".requests-menu-status", aItem.target); node.setAttribute("code", aValue); break; } case "statusText": { let node = $(".requests-menu-status-and-method", aItem.target); @@ -671,17 +672,17 @@ create({ constructor: RequestsMenuView, /** * Creates a waterfall representing timing information in a network request item view. * * @param MenuItem aItem * The network request item in this container. * @param object aTimings * An object containing timing information. */ - _createWaterfallView: function NVRM__createWaterfallView(aItem, aTimings) { + _createWaterfallView: function(aItem, aTimings) { let { target, attachment } = aItem; let sections = ["dns", "connect", "send", "wait", "receive"]; // Skipping "blocked" because it doesn't work yet. let timingsNode = $(".requests-menu-timings", target); let startCapNode = $(".requests-menu-timings-cap.start", timingsNode); let endCapNode = $(".requests-menu-timings-cap.end", timingsNode); let firstBox; @@ -718,17 +719,17 @@ create({ constructor: RequestsMenuView, }, /** * Rescales and redraws all the waterfall views in this container. * * @param boolean aReset * True if this container's width was changed. */ - _flushWaterfallViews: function NVRM__flushWaterfallViews(aReset) { + _flushWaterfallViews: function(aReset) { // To avoid expensive operations like getBoundingClientRect() and // rebuilding the waterfall background each time a new request comes in, // stuff is cached. However, in certain scenarios like when the window // is resized, this needs to be invalidated. if (aReset) { this._cachedWaterfallWidth = 0; this._hideOverflowingColumns(); } @@ -772,17 +773,17 @@ create({ constructor: RequestsMenuView, }, /** * Creates the labels displayed on the waterfall header in this container. * * @param number aScale * The current waterfall scale. */ - _showWaterfallDivisionLabels: function NVRM__showWaterfallDivisionLabels(aScale) { + _showWaterfallDivisionLabels: function(aScale) { let container = $("#requests-menu-waterfall-header-box"); let availableWidth = this._waterfallWidth - REQUESTS_WATERFALL_SAFE_BOUNDS; // Nuke all existing labels. while (container.hasChildNodes()) { container.firstChild.remove(); } @@ -819,17 +820,17 @@ create({ constructor: RequestsMenuView, }, /** * Creates the background displayed on each waterfall view in this container. * * @param number aScale * The current waterfall scale. */ - _drawWaterfallBackground: function NVRM__drawWaterfallBackground(aScale) { + _drawWaterfallBackground: function(aScale) { if (!this._canvas || !this._ctx) { this._canvas = document.createElementNS(HTML_NS, "canvas"); this._ctx = this._canvas.getContext("2d"); } let canvas = this._canvas; let ctx = this._ctx; // Nuke the context. @@ -841,58 +842,59 @@ create({ constructor: RequestsMenuView, let pixelArray = imageData.data; let buf = new ArrayBuffer(pixelArray.length); let buf8 = new Uint8ClampedArray(buf); let data32 = new Uint32Array(buf); // Build new millisecond tick lines... let timingStep = REQUESTS_WATERFALL_BACKGROUND_TICKS_MULTIPLE; + let [r, g, b] = REQUESTS_WATERFALL_BACKGROUND_TICKS_COLOR_RGB; let alphaComponent = REQUESTS_WATERFALL_BACKGROUND_TICKS_OPACITY_MIN; let optimalTickIntervalFound = false; while (!optimalTickIntervalFound) { // Ignore any divisions that would end up being too close to each other. let scaledStep = aScale * timingStep; if (scaledStep < REQUESTS_WATERFALL_BACKGROUND_TICKS_SPACING_MIN) { timingStep <<= 1; continue; } optimalTickIntervalFound = true; // Insert one pixel for each division on each scale. for (let i = 1; i <= REQUESTS_WATERFALL_BACKGROUND_TICKS_SCALES; i++) { let increment = scaledStep * Math.pow(2, i); for (let x = 0; x < canvasWidth; x += increment) { - data32[x | 0] = (alphaComponent << 24) | (255 << 16) | (255 << 8) | 255; + data32[x | 0] = (alphaComponent << 24) | (b << 16) | (g << 8) | r; } alphaComponent += REQUESTS_WATERFALL_BACKGROUND_TICKS_OPACITY_ADD; } } // Flush the image data and cache the waterfall background. pixelArray.set(buf8); ctx.putImageData(imageData, 0, 0); this._cachedWaterfallBackground = "url(" + canvas.toDataURL() + ")"; }, /** * Reapplies the current waterfall background on all request items. */ - _flushWaterfallBackgrounds: function NVRM__flushWaterfallBackgrounds() { + _flushWaterfallBackgrounds: function() { for (let [, { target }] of this._cache) { let waterfallNode = $(".requests-menu-waterfall", target); waterfallNode.style.backgroundImage = this._cachedWaterfallBackground; } }, /** * Hides the overflowing columns in the requests table. */ - _hideOverflowingColumns: function NVRM__hideOverflowingColumns() { + _hideOverflowingColumns: function() { let table = $("#network-table"); let toolbar = $("#requests-menu-toolbar"); let columns = [ ["#requests-menu-waterfall-header-box", "waterfall-overflows"], ["#requests-menu-size-header-box", "size-overflows"], ["#requests-menu-type-header-box", "type-overflows"], ["#requests-menu-domain-header-box", "domain-overflows"] ]; @@ -911,69 +913,69 @@ create({ constructor: RequestsMenuView, }, /** * Function called each time a network request item is removed. * * @param MenuItem aItem * The corresponding menu item. */ - _onRequestItemRemoved: function NVRM__onRequestItemRemoved(aItem) { + _onRequestItemRemoved: function(aItem) { dumpn("Finalizing network request item: " + aItem); this._cache.delete(aItem.attachment.id); }, /** * The mouse down listener for this container. */ - _onMouseDown: function NVRM__onMouseDown(e) { + _onMouseDown: function(e) { let item = this.getItemForElement(e.target); if (item) { // The container is not empty and we clicked on an actual item. this.selectedItem = item; } }, /** * The selection listener for this container. */ - _onSelect: function NVRM__onSelect(e) { + _onSelect: function(e) { NetMonitorView.NetworkDetails.populate(this.selectedItem.attachment); NetMonitorView.NetworkDetails.toggle(true); }, /** * The resize listener for this container's window. */ - _onResize: function NVRM__onResize(e) { + _onResize: function(e) { // Allow requests to settle down first. drain("resize-events", RESIZE_REFRESH_RATE, () => this._flushWaterfallViews(true)); }, /** * Checks if the specified unix time is the first one to be known of, * and saves it if so. * * @param number aUnixTime * The milliseconds to check and save. */ - _registerFirstRequestStart: function NVRM__registerFirstRequestStart(aUnixTime) { + _registerFirstRequestStart: function(aUnixTime) { if (this._firstRequestStartedMillis == -1) { this._firstRequestStartedMillis = aUnixTime; } }, /** * Checks if the specified unix time is the last one to be known of, * and saves it if so. * * @param number aUnixTime * The milliseconds to check and save. */ - _registerLastRequestEnd: function NVRM__registerLastRequestEnd(aUnixTime) { + _registerLastRequestEnd: function(aUnixTime) { if (this._lastRequestEndedMillis < aUnixTime) { this._lastRequestEndedMillis = aUnixTime; } }, /** * Gets the available waterfall width in this container. * @return number @@ -1001,23 +1003,25 @@ create({ constructor: RequestsMenuView, _resizeTimeout: null }); /** * Functions handling the requests details view. */ function NetworkDetailsView() { dumpn("NetworkDetailsView was instantiated"); + + this._onTabSelect = this._onTabSelect.bind(this); }; create({ constructor: NetworkDetailsView, proto: MenuContainer.prototype }, { /** * Initialization function, called when the network monitor is started. */ - initialize: function NVND_initialize() { + initialize: function() { dumpn("Initializing the RequestsMenuView"); this.node = $("#details-pane"); this._headers = new VariablesView($("#all-headers"), Object.create(GENERIC_VARIABLES_VIEW_SETTINGS, { emptyText: { value: L10N.getStr("headersEmptyText"), enumerable: true }, searchPlaceholder: { value: L10N.getStr("headersFilterText"), enumerable: true } @@ -1039,75 +1043,113 @@ create({ constructor: NetworkDetailsView this._paramsQueryString = L10N.getStr("paramsQueryString"); this._paramsFormData = L10N.getStr("paramsFormData"); this._paramsPostPayload = L10N.getStr("paramsPostPayload"); this._requestHeaders = L10N.getStr("requestHeaders"); this._responseHeaders = L10N.getStr("responseHeaders"); this._requestCookies = L10N.getStr("requestCookies"); this._responseCookies = L10N.getStr("responseCookies"); + + $("tabpanels", this.node).addEventListener("select", this._onTabSelect); }, /** * Destruction function, called when the network monitor is closed. */ - destroy: function NVND_destroy() { + destroy: function() { dumpn("Destroying the SourcesView"); }, /** * Sets this view hidden or visible. It's visible by default. * * @param boolean aVisibleFlag * Specifies the intended visibility. */ - toggle: function NVND_toggle(aVisibleFlag) { + toggle: function(aVisibleFlag) { NetMonitorView.toggleDetailsPane({ visible: aVisibleFlag }); NetMonitorView.RequestsMenu._flushWaterfallViews(true); }, /** + * Hides and resets this container (removes all the networking information). + */ + reset: function() { + this.toggle(false); + this._dataSrc = null; + }, + + /** * Populates this view with the specified data. * * @param object aData * The data source (this should be the attachment of a request item). */ - populate: function NVND_populate(aData) { + populate: function(aData) { $("#request-params-box").setAttribute("flex", "1"); $("#request-params-box").hidden = false; $("#request-post-data-textarea-box").hidden = true; $("#response-content-json-box").hidden = true; $("#response-content-textarea-box").hidden = true; $("#response-content-image-box").hidden = true; this._headers.empty(); this._cookies.empty(); this._params.empty(); this._json.empty(); - if (aData) { - this._setSummary(aData); - this._setResponseHeaders(aData.responseHeaders); - this._setRequestHeaders(aData.requestHeaders); - this._setResponseCookies(aData.responseCookies); - this._setRequestCookies(aData.requestCookies); - this._setRequestGetParams(aData.url); - this._setRequestPostParams(aData.requestHeaders, aData.requestPostData); - this._setResponseBody(aData.url, aData.responseContent); - this._setTimingsInformation(aData.eventTimings); + this._dataSrc = { src: aData, populated: [] }; + this._onTabSelect(); + }, + + /** + * Listener handling the tab selection event. + */ + _onTabSelect: function() { + let { src, populated } = this._dataSrc || {}; + let tab = this.node.selectedIndex; + + // Make sure the data source is valid and don't populate the same tab twice. + if (!src || populated[tab]) { + return; } + + switch (tab) { + case 0: // "Headers" + this._setSummary(src); + this._setResponseHeaders(src.responseHeaders); + this._setRequestHeaders(src.requestHeaders); + break; + case 1: // "Cookies" + this._setResponseCookies(src.responseCookies); + this._setRequestCookies(src.requestCookies); + break; + case 2: // "Params" + this._setRequestGetParams(src.url); + this._setRequestPostParams(src.requestHeaders, src.requestPostData); + break; + case 3: // "Response" + this._setResponseBody(src.url, src.responseContent); + break; + case 4: // "Timings" + this._setTimingsInformation(src.eventTimings); + break; + } + + populated[tab] = true; }, /** * Sets the network request summary shown in this view. * * @param object aData * The data source (this should be the attachment of a request item). */ - _setSummary: function NVND__setSummary(aData) { + _setSummary: function(aData) { if (aData.url) { let unicodeUrl = NetworkHelper.convertToUnicode(unescape(aData.url)); $("#headers-summary-url-value").setAttribute("value", unicodeUrl); $("#headers-summary-url-value").setAttribute("tooltiptext", unicodeUrl); $("#headers-summary-url").removeAttribute("hidden"); } else { $("#headers-summary-url").setAttribute("hidden", "true"); } @@ -1136,44 +1178,44 @@ create({ constructor: NetworkDetailsView }, /** * Sets the network request headers shown in this view. * * @param object aResponse * The message received from the server. */ - _setRequestHeaders: function NVND__setRequestHeaders(aResponse) { + _setRequestHeaders: function(aResponse) { if (aResponse && aResponse.headers.length) { this._addHeaders(this._requestHeaders, aResponse); } }, /** * Sets the network response headers shown in this view. * * @param object aResponse * The message received from the server. */ - _setResponseHeaders: function NVND__setResponseHeaders(aResponse) { + _setResponseHeaders: function(aResponse) { if (aResponse && aResponse.headers.length) { aResponse.headers.sort((a, b) => a.name > b.name); this._addHeaders(this._responseHeaders, aResponse); } }, /** * Populates the headers container in this view with the specified data. * * @param string aName * The type of headers to populate (request or response). * @param object aResponse * The message received from the server. */ - _addHeaders: function NVND__addHeaders(aName, aResponse) { + _addHeaders: function(aName, aResponse) { let kb = aResponse.headersSize / 1024; let size = L10N.numberWithDecimals(kb, HEADERS_SIZE_DECIMALS); let text = L10N.getFormatStr("networkMenu.sizeKB", size); let headersScope = this._headers.addScope(aName + " (" + text + ")"); headersScope.expanded = true; for (let header of aResponse.headers) { let headerVar = headersScope.addVar(header.name, { null: true }, true); @@ -1182,44 +1224,44 @@ create({ constructor: NetworkDetailsView }, /** * Sets the network request cookies shown in this view. * * @param object aResponse * The message received from the server. */ - _setRequestCookies: function NVND__setRequestCookies(aResponse) { + _setRequestCookies: function(aResponse) { if (aResponse && aResponse.cookies.length) { aResponse.cookies.sort((a, b) => a.name > b.name); this._addCookies(this._requestCookies, aResponse); } }, /** * Sets the network response cookies shown in this view. * * @param object aResponse * The message received from the server. */ - _setResponseCookies: function NVND__setResponseCookies(aResponse) { + _setResponseCookies: function(aResponse) { if (aResponse && aResponse.cookies.length) { this._addCookies(this._responseCookies, aResponse); } }, /** * Populates the cookies container in this view with the specified data. * * @param string aName * The type of cookies to populate (request or response). * @param object aResponse * The message received from the server. */ - _addCookies: function NVND__addCookies(aName, aResponse) { + _addCookies: function(aName, aResponse) { let cookiesScope = this._cookies.addScope(aName); cookiesScope.expanded = true; for (let cookie of aResponse.cookies) { let cookieVar = cookiesScope.addVar(cookie.name, { null: true }, true); gNetwork.getString(cookie.value).then((aString) => cookieVar.setGrip(aString)); // By default the cookie name and value are shown. If this is the only @@ -1243,33 +1285,33 @@ create({ constructor: NetworkDetailsView }, /** * Sets the network request get params shown in this view. * * @param string aUrl * The request's url. */ - _setRequestGetParams: function NVND__setRequestGetParams(aUrl) { + _setRequestGetParams: function(aUrl) { let uri = Services.io.newURI(aUrl, null, null).QueryInterface(Ci.nsIURL); let query = uri.query; if (query) { this._addParams(this._paramsQueryString, query); } }, /** * Sets the network request post params shown in this view. * * @param object aHeadersResponse * The "requestHeaders" message received from the server. * @param object aPostResponse * The "requestPostData" message received from the server. */ - _setRequestPostParams: function NVND__setRequestPostParams(aHeadersResponse, aPostResponse) { + _setRequestPostParams: function(aHeadersResponse, aPostResponse) { if (!aHeadersResponse || !aPostResponse) { return; } let contentType = aHeadersResponse.headers.filter(({ name }) => name == "Content-Type")[0]; let text = aPostResponse.postData.text; gNetwork.getString(text).then((aString) => { // Handle query strings (poor man's forms, e.g. "?foo=bar&baz=42"). @@ -1298,17 +1340,17 @@ create({ constructor: NetworkDetailsView /** * Populates the params container in this view with the specified data. * * @param string aName * The type of params to populate (get or post). * @param string aParams * A query string of params (e.g. "?foo=bar&baz=42"). */ - _addParams: function NVND__addParams(aName, aParams) { + _addParams: function(aName, aParams) { // Turn the params string into an array containing { name: value } tuples. let paramsArray = aParams.replace(/^[?&]/, "").split("&").map((e) => let (param = e.split("=")) { name: NetworkHelper.convertToUnicode(unescape(param[0])), value: NetworkHelper.convertToUnicode(unescape(param[1])) }); let paramsScope = this._params.addScope(aName); @@ -1323,17 +1365,17 @@ create({ constructor: NetworkDetailsView /** * Sets the network response body shown in this view. * * @param string aUrl * The request's url. * @param object aResponse * The message received from the server. */ - _setResponseBody: function NVND__setresponseBody(aUrl, aResponse) { + _setResponseBody: function(aUrl, aResponse) { if (!aResponse) { return; } let uri = Services.io.newURI(aUrl, null, null).QueryInterface(Ci.nsIURL); let { mimeType, text, encoding } = aResponse.content; gNetwork.getString(text).then((aString) => { // Handle json. @@ -1396,17 +1438,17 @@ create({ constructor: NetworkDetailsView }, /** * Sets the timings information shown in this view. * * @param object aResponse * The message received from the server. */ - _setTimingsInformation: function NVND__setTimingsInformation(aResponse) { + _setTimingsInformation: function(aResponse) { if (!aResponse) { return; } let { blocked, dns, connect, send, wait, receive } = aResponse.timings; let tabboxWidth = $("#details-pane").getAttribute("width"); let availableWidth = tabboxWidth / 2; // Other nodes also take some space. let scale = Math.max(availableWidth / aResponse.totalTime, 0); @@ -1459,16 +1501,17 @@ create({ constructor: NetworkDetailsView $("#timings-summary-send .requests-menu-timings-total") .style.transform = "translateX(" + (scale * (blocked + dns + connect)) + "px)"; $("#timings-summary-wait .requests-menu-timings-total") .style.transform = "translateX(" + (scale * (blocked + dns + connect + send)) + "px)"; $("#timings-summary-receive .requests-menu-timings-total") .style.transform = "translateX(" + (scale * (blocked + dns + connect + send + wait)) + "px)"; }, + _dataSrc: null, _headers: null, _cookies: null, _params: null, _json: null, _paramsQueryString: "", _paramsFormData: "", _paramsPostPayload: "", _requestHeaders: "",
--- a/browser/devtools/netmonitor/test/browser_net_autoscroll.js +++ b/browser/devtools/netmonitor/test/browser_net_autoscroll.js @@ -15,17 +15,16 @@ function test() { let topNode = win.document.getElementById("requests-menu-contents"); requestsContainer = topNode.getElementsByTagName("scrollbox")[0]; ok(!!requestsContainer, "Container element exists as expected."); }) // (1) Check that the scroll position is maintained at the bottom // when the requests overflow the vertical size of the container. .then(() => { - debuggee.performRequests(); return waitForRequestsToOverflowContainer(monitor, requestsContainer); }).then(() => { ok(scrolledToBottom(requestsContainer), "Scrolled to bottom on overflow."); }) // (2) Now set the scroll position somewhere in the middle and check // that additional requests do not change the scroll position. .then(() => {
--- a/browser/devtools/netmonitor/test/browser_net_sort-02.js +++ b/browser/devtools/netmonitor/test/browser_net_sort-02.js @@ -4,16 +4,20 @@ /** * Test if sorting columns in the network table works correctly. */ function test() { initNetMonitor(SORTING_URL).then(([aTab, aDebuggee, aMonitor]) => { info("Starting test... "); + // It seems that this test may be slow on debug builds. This could be because + // of the heavy dom manipulation associated with sorting. + requestLongerTimeout(2); + let { $, L10N, NetMonitorView } = aMonitor.panelWin; let { RequestsMenu } = NetMonitorView; RequestsMenu.lazyUpdate = false; waitForNetworkEvents(aMonitor, 5).then(() => { EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle")); @@ -167,52 +171,57 @@ function test() { "The requests menu items aren't ordered correctly. Third item is misplaced."); is(RequestsMenu.getItemAtIndex(3), RequestsMenu.allItems[3], "The requests menu items aren't ordered correctly. Fourth item is misplaced."); is(RequestsMenu.getItemAtIndex(4), RequestsMenu.allItems[4], "The requests menu items aren't ordered correctly. Fifth item is misplaced."); verifyRequestItemTarget(RequestsMenu.getItemAtIndex(a), "GET1", SORTING_SJS + "?index=1", { + fuzzyUrl: true, status: 101, statusText: "Meh", type: "1", fullMimeType: "text/1", size: L10N.getFormatStr("networkMenu.sizeKB", 0), time: true }); verifyRequestItemTarget(RequestsMenu.getItemAtIndex(b), "GET2", SORTING_SJS + "?index=2", { + fuzzyUrl: true, status: 200, statusText: "Meh", type: "2", fullMimeType: "text/2", size: L10N.getFormatStr("networkMenu.sizeKB", 0.01), time: true }); verifyRequestItemTarget(RequestsMenu.getItemAtIndex(c), "GET3", SORTING_SJS + "?index=3", { + fuzzyUrl: true, status: 300, statusText: "Meh", type: "3", fullMimeType: "text/3", size: L10N.getFormatStr("networkMenu.sizeKB", 0.02), time: true }); verifyRequestItemTarget(RequestsMenu.getItemAtIndex(d), "GET4", SORTING_SJS + "?index=4", { + fuzzyUrl: true, status: 400, statusText: "Meh", type: "4", fullMimeType: "text/4", size: L10N.getFormatStr("networkMenu.sizeKB", 0.03), time: true }); verifyRequestItemTarget(RequestsMenu.getItemAtIndex(e), "GET5", SORTING_SJS + "?index=5", { + fuzzyUrl: true, status: 500, statusText: "Meh", type: "5", fullMimeType: "text/5", size: L10N.getFormatStr("networkMenu.sizeKB", 0.04), time: true });
--- a/browser/devtools/netmonitor/test/browser_net_sort-03.js +++ b/browser/devtools/netmonitor/test/browser_net_sort-03.js @@ -4,16 +4,20 @@ /** * Test if sorting columns in the network table works correctly with new requests. */ function test() { initNetMonitor(SORTING_URL).then(([aTab, aDebuggee, aMonitor]) => { info("Starting test... "); + // It seems that this test may be slow on debug builds. This could be because + // of the heavy dom manipulation associated with sorting. + requestLongerTimeout(2); + let { $, L10N, NetMonitorView } = aMonitor.panelWin; let { RequestsMenu } = NetMonitorView; RequestsMenu.lazyUpdate = false; waitForNetworkEvents(aMonitor, 5).then(() => { EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle")); @@ -104,60 +108,65 @@ function test() { for (let i = 0; i < aOrder.length; i++) { is(RequestsMenu.getItemAtIndex(i), RequestsMenu.allItems[i], "The requests menu items aren't ordered correctly. Misplaced item " + i + "."); } for (let i = 0, len = aOrder.length / 5; i < len; i++) { verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i]), "GET1", SORTING_SJS + "?index=1", { + fuzzyUrl: true, status: 101, statusText: "Meh", type: "1", fullMimeType: "text/1", size: L10N.getFormatStr("networkMenu.sizeKB", 0), time: true }); } for (let i = 0, len = aOrder.length / 5; i < len; i++) { verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len]), "GET2", SORTING_SJS + "?index=2", { + fuzzyUrl: true, status: 200, statusText: "Meh", type: "2", fullMimeType: "text/2", size: L10N.getFormatStr("networkMenu.sizeKB", 0.01), time: true }); } for (let i = 0, len = aOrder.length / 5; i < len; i++) { verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 2]), "GET3", SORTING_SJS + "?index=3", { + fuzzyUrl: true, status: 300, statusText: "Meh", type: "3", fullMimeType: "text/3", size: L10N.getFormatStr("networkMenu.sizeKB", 0.02), time: true }); } for (let i = 0, len = aOrder.length / 5; i < len; i++) { verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 3]), "GET4", SORTING_SJS + "?index=4", { + fuzzyUrl: true, status: 400, statusText: "Meh", type: "4", fullMimeType: "text/4", size: L10N.getFormatStr("networkMenu.sizeKB", 0.03), time: true }); } for (let i = 0, len = aOrder.length / 5; i < len; i++) { verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 4]), "GET5", SORTING_SJS + "?index=5", { + fuzzyUrl: true, status: 500, statusText: "Meh", type: "5", fullMimeType: "text/5", size: L10N.getFormatStr("networkMenu.sizeKB", 0.04), time: true }); }
--- a/browser/devtools/netmonitor/test/head.js +++ b/browser/devtools/netmonitor/test/head.js @@ -1,17 +1,18 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components; let { Services } = Cu.import("resource://gre/modules/Services.jsm", {}); let { Promise } = Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", {}); -let { gDevTools, devtools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {}); +let { gDevTools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {}); +let { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); let TargetFactory = devtools.TargetFactory; let Toolbox = devtools.Toolbox; const EXAMPLE_URL = "http://example.com/browser/browser/devtools/netmonitor/test/"; const SIMPLE_URL = EXAMPLE_URL + "html_simple-test-page.html"; const NAVIGATE_URL = EXAMPLE_URL + "html_navigate-test-page.html"; const CONTENT_TYPE_URL = EXAMPLE_URL + "html_content-type-test-page.html"; @@ -180,37 +181,46 @@ function waitForNetworkEvents(aMonitor, return deferred.promise; } function verifyRequestItemTarget(aRequestItem, aMethod, aUrl, aData = {}) { info("> Verifying: " + aMethod + " " + aUrl + " " + aData.toSource()); info("> Request: " + aRequestItem.attachment.toSource()); - let { status, statusText, type, fullMimeType, size, time } = aData; + let { fuzzyUrl, status, statusText, type, fullMimeType, size, time } = aData; let { attachment, target } = aRequestItem let uri = Services.io.newURI(aUrl, null, null).QueryInterface(Ci.nsIURL); let name = uri.fileName || "/"; let query = uri.query; let hostPort = uri.hostPort; - is(attachment.method, aMethod, - "The attached method is incorrect."); - - is(attachment.url, aUrl, - "The attached url is incorrect."); + if (fuzzyUrl) { + ok(attachment.method.startsWith(aMethod), "The attached method is incorrect."); + ok(attachment.url.startsWith(aUrl), "The attached url is incorrect."); + } else { + is(attachment.method, aMethod, "The attached method is incorrect."); + is(attachment.url, aUrl, "The attached url is incorrect."); + } is(target.querySelector(".requests-menu-method").getAttribute("value"), aMethod, "The displayed method is incorrect."); - is(target.querySelector(".requests-menu-file").getAttribute("value"), - name + (query ? "?" + query : ""), "The displayed file is incorrect."); - is(target.querySelector(".requests-menu-file").getAttribute("tooltiptext"), - name + (query ? "?" + query : ""), "The tooltip file is incorrect."); + if (fuzzyUrl) { + ok(target.querySelector(".requests-menu-file").getAttribute("value").startsWith( + name + (query ? "?" + query : "")), "The displayed file is incorrect."); + ok(target.querySelector(".requests-menu-file").getAttribute("tooltiptext").startsWith( + name + (query ? "?" + query : "")), "The tooltip file is incorrect."); + } else { + is(target.querySelector(".requests-menu-file").getAttribute("value"), + name + (query ? "?" + query : ""), "The displayed file is incorrect."); + is(target.querySelector(".requests-menu-file").getAttribute("tooltiptext"), + name + (query ? "?" + query : ""), "The tooltip file is incorrect."); + } is(target.querySelector(".requests-menu-domain").getAttribute("value"), hostPort, "The displayed domain is incorrect."); is(target.querySelector(".requests-menu-domain").getAttribute("tooltiptext"), hostPort, "The tooltip domain is incorrect."); if (status !== undefined) { let value = target.querySelector(".requests-menu-status").getAttribute("code");
--- a/browser/devtools/netmonitor/test/html_infinite-get-page.html +++ b/browser/devtools/netmonitor/test/html_infinite-get-page.html @@ -20,17 +20,17 @@ } }; xhr.send(null); } // Use a count parameter to defeat caching. var count = 0; - function performRequests() { + (function performRequests() { get("request_" + (count++), function() { setTimeout(performRequests, 0); }); - } + })(); </script> </body> </html>
--- a/browser/devtools/netmonitor/test/html_sorting-test-page.html +++ b/browser/devtools/netmonitor/test/html_sorting-test-page.html @@ -7,17 +7,18 @@ </head> <body> <p>Sorting test</p> <script type="text/javascript"> function get(aAddress, aIndex, aCallback) { var xhr = new XMLHttpRequest(); - xhr.open("GET" + aIndex, aAddress + "?index=" + aIndex, true); + // Use a random parameter to defeat caching. + xhr.open("GET" + aIndex, aAddress + "?index=" + aIndex + "&" + Math.random(), true); xhr.onreadystatechange = function() { if (this.readyState == this.DONE) { aCallback(); } }; xhr.send(null); }
--- a/browser/devtools/netmonitor/test/sjs_sorting-test-server.sjs +++ b/browser/devtools/netmonitor/test/sjs_sorting-test-server.sjs @@ -9,10 +9,10 @@ function handleRequest(request, response let params = request.queryString.split("&"); let index = params.filter((s) => s.contains("index="))[0].split("=")[1]; Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer).initWithCallback(() => { response.setStatusLine(request.httpVersion, index == 1 ? 101 : index * 100, "Meh"); response.setHeader("Content-Type", "text/" + index, false); response.write(new Array(index * 10).join(index)); // + 0.01 KB response.finish(); - }, 50, Ci.nsITimer.TYPE_ONE_SHOT); // Make sure this request takes a few ms. + }, 10, Ci.nsITimer.TYPE_ONE_SHOT); // Make sure this request takes a few ms. }
--- a/browser/devtools/profiler/test/head.js +++ b/browser/devtools/profiler/test/head.js @@ -2,16 +2,18 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ let temp = {}; const PROFILER_ENABLED = "devtools.profiler.enabled"; const REMOTE_ENABLED = "devtools.debugger.remote-enabled"; Cu.import("resource:///modules/devtools/gDevTools.jsm", temp); let gDevTools = temp.gDevTools; + +Cu.import("resource://gre/modules/devtools/Loader.jsm", temp); let TargetFactory = temp.devtools.TargetFactory; Cu.import("resource://gre/modules/devtools/dbg-server.jsm", temp); let DebuggerServer = temp.DebuggerServer; // Import the GCLI test helper let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/")); Services.scriptloader.loadSubScript(testDir + "../../../commandline/test/helpers.js", this);
--- a/browser/devtools/scratchpad/scratchpad.js +++ b/browser/devtools/scratchpad/scratchpad.js @@ -28,17 +28,17 @@ Cu.import("resource://gre/modules/jsdebu Cu.import("resource:///modules/devtools/gDevTools.jsm"); Cu.import("resource://gre/modules/osfile.jsm"); Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js"); XPCOMUtils.defineLazyModuleGetter(this, "VariablesView", "resource:///modules/devtools/VariablesView.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "devtools", - "resource:///modules/devtools/gDevTools.jsm"); + "resource://gre/modules/devtools/Loader.jsm"); const SCRATCHPAD_CONTEXT_CONTENT = 1; const SCRATCHPAD_CONTEXT_BROWSER = 2; const SCRATCHPAD_L10N = "chrome://browser/locale/devtools/scratchpad.properties"; const DEVTOOLS_CHROME_ENABLED = "devtools.chrome.enabled"; const PREF_RECENT_FILES_MAX = "devtools.scratchpad.recentFilesMax"; const BUTTON_POSITION_SAVE = 0; const BUTTON_POSITION_CANCEL = 1;
--- a/browser/devtools/shared/DeveloperToolbar.jsm +++ b/browser/devtools/shared/DeveloperToolbar.jsm @@ -26,17 +26,17 @@ XPCOMUtils.defineLazyModuleGetter(this, XPCOMUtils.defineLazyModuleGetter(this, "PageErrorListener", "resource://gre/modules/devtools/WebConsoleUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "PluralForm", "resource://gre/modules/PluralForm.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "devtools", - "resource:///modules/devtools/gDevTools.jsm"); + "resource://gre/modules/devtools/Loader.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "require", "resource://gre/modules/devtools/Require.jsm"); XPCOMUtils.defineLazyGetter(this, "prefBranch", function() { let prefService = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefService); return prefService.getBranch(null)
--- a/browser/devtools/shared/test/Makefile.in +++ b/browser/devtools/shared/test/Makefile.in @@ -6,18 +6,16 @@ DEPTH = @DEPTH@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ relativesrcdir = @relativesrcdir@ include $(DEPTH)/config/autoconf.mk -DISABLED_XPCSHELL_TESTS = unit - MOCHITEST_BROWSER_FILES = \ browser_require_basic.js \ browser_templater_basic.js \ browser_toolbar_basic.js \ browser_toolbar_tooltip.js \ browser_toolbar_webconsole_errors_count.js \ browser_layoutHelpers.js \ browser_eventemitter_basic.js \
--- a/browser/devtools/shared/test/head.js +++ b/browser/devtools/shared/test/head.js @@ -1,13 +1,13 @@ /* 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/. */ -let {devtools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {}); +let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); let TargetFactory = devtools.TargetFactory; /** * Open a new tab at a URL and call a callback on load */ function addTab(aURL, aCallback) { waitForExplicitFinish();
--- a/browser/devtools/shared/theme-switching.js +++ b/browser/devtools/shared/theme-switching.js @@ -13,54 +13,60 @@ return; } let display = computedStyle.display; // Save display value document.documentElement.style.display = "none"; window.getComputedStyle(document.documentElement).display; // Flush document.documentElement.style.display = display; // Restore } - function switchTheme(theme, old_theme) { + function switchTheme(newTheme, oldTheme) { let winUtils = window.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIDOMWindowUtils); - if (old_theme && theme != old_theme) { - let old_theme_url = Services.io.newURI(DEVTOOLS_SKIN_URL + old_theme + - "-theme.css", null, null); + + if (oldTheme && newTheme != oldTheme) { + let oldThemeUrl = Services.io.newURI( + DEVTOOLS_SKIN_URL + oldTheme + "-theme.css", null, null); try { - winUtils.removeSheet(old_theme_url, window.AUTHOR_SHEET); + winUtils.removeSheet(oldThemeUrl, window.AUTHOR_SHEET); } catch(ex) {} } - let theme_url = Services.io.newURI(DEVTOOLS_SKIN_URL + theme + "-theme.css", - null, null); - winUtils.loadSheet(theme_url, window.AUTHOR_SHEET); - let scrollbar_url = - Services.io.newURI(DEVTOOLS_SKIN_URL + "floating-scrollbars-light.css", - null, null); - if (theme == "dark") { - winUtils.loadSheet(scrollbar_url, window.AGENT_SHEET); - forceStyle(); + + let newThemeUrl = Services.io.newURI( + DEVTOOLS_SKIN_URL + newTheme + "-theme.css", null, null); + let scrollbarsUrl = Services.io.newURI( + DEVTOOLS_SKIN_URL + "floating-scrollbars-light.css", null, null); + + winUtils.loadSheet(newThemeUrl, window.AUTHOR_SHEET); + + if (newTheme == "dark") { + winUtils.loadSheet(scrollbarsUrl, window.AGENT_SHEET); + } else if (oldTheme == "dark") { + try { + winUtils.removeSheet(scrollbarsUrl, window.AGENT_SHEET); + } catch(ex) {} } - else if (old_theme == "dark") { - try { - winUtils.removeSheet(scrollbar_url, window.AGENT_SHEET); - } catch(ex) {} - forceStyle(); - } - document.documentElement.classList.remove("theme-" + old_theme); - document.documentElement.classList.add("theme-" + theme); + + forceStyle(); + + document.documentElement.classList.remove("theme-" + oldTheme); + document.documentElement.classList.add("theme-" + newTheme); } function handlePrefChange(event, data) { if (data.pref == "devtools.theme") { - switchTheme(data.newValue, data.oldValue); + switchTheme(data.newValue, data.oldValue); } } const { classes: Cc, interfaces: Ci, utils: Cu } = Components; + Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource:///modules/devtools/gDevTools.jsm"); + let theme = Services.prefs.getCharPref("devtools.theme"); switchTheme(theme); + gDevTools.on("pref-changed", handlePrefChange); window.addEventListener("unload", function() { gDevTools.off("pref-changed", handlePrefChange); }); -})() +})();
--- a/browser/devtools/shared/widgets/BreadcrumbsWidget.jsm +++ b/browser/devtools/shared/widgets/BreadcrumbsWidget.jsm @@ -66,52 +66,52 @@ BreadcrumbsWidget.prototype = { * * @param number aIndex * The position in the container intended for this item. * @param string | nsIDOMNode aContents * The string or node displayed in the container. * @return nsIDOMNode * The element associated with the displayed item. */ - insertItemAt: function BCW_insertItemAt(aIndex, aContents) { + insertItemAt: function(aIndex, aContents) { let list = this._list; let breadcrumb = new Breadcrumb(this, aContents); return list.insertBefore(breadcrumb._target, list.childNodes[aIndex]); }, /** * Returns the child node in this container situated at the specified index. * * @param number aIndex * The position in the container intended for this item. * @return nsIDOMNode * The element associated with the displayed item. */ - getItemAtIndex: function BCW_getItemAtIndex(aIndex) { + getItemAtIndex: function(aIndex) { return this._list.childNodes[aIndex]; }, /** * Removes the specified child node from this container. * * @param nsIDOMNode aChild * The element associated with the displayed item. */ - removeChild: function BCW_removeChild(aChild) { + removeChild: function(aChild) { this._list.removeChild(aChild); if (this._selectedItem == aChild) { this._selectedItem = null; } }, /** * Removes all of the child nodes from this container. */ - removeAllItems: function BCW_removeAllItems() { + removeAllItems: function() { let list = this._list; while (list.hasChildNodes()) { list.firstChild.remove(); } this._selectedItem = null; }, @@ -149,29 +149,29 @@ BreadcrumbsWidget.prototype = { this._list.ensureElementIsVisible(this._selectedItem); } }, ENSURE_SELECTION_VISIBLE_DELAY); }, /** * The underflow and overflow listener for the arrowscrollbox container. */ - _onUnderflow: function BCW__onUnderflow({target}) { + _onUnderflow: function({ target }) { if (target != this._list) { return; } target._scrollButtonUp.collapsed = true; target._scrollButtonDown.collapsed = true; target.removeAttribute("overflows"); }, /** * The underflow and overflow listener for the arrowscrollbox container. */ - _onOverflow: function BCW__onOverflow({target}) { + _onOverflow: function({ target }) { if (target != this._list) { return; } target._scrollButtonUp.collapsed = false; target._scrollButtonDown.collapsed = false; target.setAttribute("overflows", ""); },
--- a/browser/devtools/shared/widgets/SideMenuWidget.jsm +++ b/browser/devtools/shared/widgets/SideMenuWidget.jsm @@ -91,27 +91,27 @@ SideMenuWidget.prototype = { * The string or node displayed in the container. * @param string aTooltip [optional] * A tooltip attribute for the displayed item. * @param string aGroup [optional] * The group to place the displayed item into. * @return nsIDOMNode * The element associated with the displayed item. */ - insertItemAt: function SMW_insertItemAt(aIndex, aContents, aTooltip = "", aGroup = "") { + insertItemAt: function(aIndex, aContents, aTooltip = "", aGroup = "") { // Invalidate any notices set on this widget. this.removeAttribute("notice"); let maintainScrollAtBottom = this.autoscrollWithAppendedItems && (aIndex < 0 || aIndex >= this._orderedMenuElementsArray.length) && (this._list.scrollTop + this._list.clientHeight >= this._list.scrollHeight); - let group = this._getGroupForName(aGroup); - let item = this._getItemForGroup(group, aContents, aTooltip); + let group = this._getMenuGroupForName(aGroup); + let item = this._getMenuItemForGroup(group, aContents, aTooltip); let element = item.insertSelfAt(aIndex); if (this.maintainSelectionVisible) { this.ensureSelectionIsVisible({ withGroup: true, delayed: true }); } if (maintainScrollAtBottom) { this._list.scrollTop = this._list.scrollHeight; } @@ -122,27 +122,27 @@ SideMenuWidget.prototype = { /** * Returns the child node in this container situated at the specified index. * * @param number aIndex * The position in the container intended for this item. * @return nsIDOMNode * The element associated with the displayed item. */ - getItemAtIndex: function SMW_getItemAtIndex(aIndex) { + getItemAtIndex: function(aIndex) { return this._orderedMenuElementsArray[aIndex]; }, /** * Removes the specified child node from this container. * * @param nsIDOMNode aChild * The element associated with the displayed item. */ - removeChild: function SMW_removeChild(aChild) { + removeChild: function(aChild) { if (aChild.className == "side-menu-widget-item-contents") { // Remove the item itself, not the contents. aChild.parentNode.remove(); } else { // Groups with no title don't have any special internal structure. aChild.remove(); } @@ -152,17 +152,17 @@ SideMenuWidget.prototype = { if (this._selectedItem == aChild) { this._selectedItem = null; } }, /** * Removes all of the child nodes from this container. */ - removeAllItems: function SMW_removeAllItems() { + removeAllItems: function() { let parent = this._parent; let list = this._list; while (list.hasChildNodes()) { list.firstChild.remove(); } this._selectedItem = null; @@ -203,31 +203,31 @@ SideMenuWidget.prototype = { // and may sometimes result in incorrect scroll positions. this.ensureSelectionIsVisible({ delayed: true }); }, /** * Ensures the selected element is visible. * @see SideMenuWidget.prototype.ensureElementIsVisible. */ - ensureSelectionIsVisible: function SMW_ensureSelectionIsVisible(aFlags) { + ensureSelectionIsVisible: function(aFlags) { this.ensureElementIsVisible(this.selectedItem, aFlags); }, /** * Ensures the specified element is visible. * * @param nsIDOMNode aElement * The element to make visible. * @param object aFlags [optional] * An object containing some of the following flags: * - withGroup: true if the group header should also be made visible, if possible * - delayed: wait a few cycles before ensuring the selection is visible */ - ensureElementIsVisible: function SMW_ensureElementIsVisible(aElement, aFlags = {}) { + ensureElementIsVisible: function(aElement, aFlags = {}) { if (!aElement) { return; } if (aFlags.delayed) { delete aFlags.delayed; this.window.clearTimeout(this._ensureVisibleTimeout); this._ensureVisibleTimeout = this.window.setTimeout(() => { @@ -243,26 +243,26 @@ SideMenuWidget.prototype = { } this._boxObject.ensureElementIsVisible(aElement); }, /** * Shows all the groups, even the ones with no visible children. */ - showEmptyGroups: function SMW_showEmptyGroups() { + showEmptyGroups: function() { for (let group of this._orderedGroupElementsArray) { group.hidden = false; } }, /** * Hides all the groups which have no visible children. */ - hideEmptyGroups: function SMW_hideEmptyGroups() { + hideEmptyGroups: function() { let visibleChildNodes = ".side-menu-widget-item-contents:not([hidden=true])"; for (let group of this._orderedGroupElementsArray) { group.hidden = group.querySelectorAll(visibleChildNodes).length == 0; } for (let menuItem of this._orderedMenuElementsArray) { menuItem.parentNode.hidden = menuItem.hidden; } @@ -271,43 +271,43 @@ SideMenuWidget.prototype = { /** * Returns the value of the named attribute on this container. * * @param string aName * The name of the attribute. * @return string * The current attribute value. */ - getAttribute: function SMW_getAttribute(aName) { + getAttribute: function(aName) { return this._parent.getAttribute(aName); }, /** * Adds a new attribute or changes an existing attribute on this container. * * @param string aName * The name of the attribute. * @param string aValue * The desired attribute value. */ - setAttribute: function SMW_setAttribute(aName, aValue) { + setAttribute: function(aName, aValue) { this._parent.setAttribute(aName, aValue); if (aName == "notice") { this.notice = aValue; } }, /** * Removes an attribute on this container. * * @param string aName * The name of the attribute. */ - removeAttribute: function SMW_removeAttribute(aName) { + removeAttribute: function(aName) { this._parent.removeAttribute(aName); if (aName == "notice") { this._removeNotice(); } }, /** @@ -320,17 +320,17 @@ SideMenuWidget.prototype = { } this._noticeTextValue = aValue; this._appendNotice(); }, /** * Creates and appends a label representing a notice in this container. */ - _appendNotice: function DVSL__appendNotice() { + _appendNotice: function() { if (this._noticeTextNode || !this._noticeTextValue) { return; } let container = this.document.createElement("vbox"); container.className = "side-menu-widget-empty-notice-container"; container.setAttribute("align", "center"); @@ -342,17 +342,17 @@ SideMenuWidget.prototype = { this._parent.insertBefore(container, this._list); this._noticeTextContainer = container; this._noticeTextNode = label; }, /** * Removes the label representing a notice in this container. */ - _removeNotice: function DVSL__removeNotice() { + _removeNotice: function() { if (!this._noticeTextNode) { return; } this._parent.removeChild(this._noticeTextContainer); this._noticeTextContainer = null; this._noticeTextNode = null; }, @@ -361,40 +361,40 @@ SideMenuWidget.prototype = { * Gets a container representing a group for menu items. If the container * is not available yet, it is immediately created. * * @param string aName * The required group name. * @return SideMenuGroup * The newly created group. */ - _getGroupForName: function SMW__getGroupForName(aName) { + _getMenuGroupForName: function(aName) { let cachedGroup = this._groupsByName.get(aName); if (cachedGroup) { return cachedGroup; } let group = new SideMenuGroup(this, aName); this._groupsByName.set(aName, group); group.insertSelfAt(this.sortedGroups ? group.findExpectedIndexForSelf() : -1); return group; }, /** * Gets a menu item to be displayed inside a group. - * @see SideMenuWidget.prototype._getGroupForName + * @see SideMenuWidget.prototype._getMenuGroupForName * * @param SideMenuGroup aGroup * The group to contain the menu item. * @param string | nsIDOMNode aContents * The string or node displayed in the container. * @param string aTooltip [optional] * A tooltip attribute for the displayed item. */ - _getItemForGroup: function SMW__getItemForGroup(aGroup, aContents, aTooltip) { + _getMenuItemForGroup: function(aGroup, aContents, aTooltip) { return new SideMenuItem(aGroup, aContents, aTooltip, this._showArrows); }, window: null, document: null, _showArrows: false, _parent: null, _list: null, @@ -459,17 +459,17 @@ SideMenuGroup.prototype = { get _orderedMenuElementsArray() this.ownerView._orderedMenuElementsArray, /** * Inserts this group in the parent container at the specified index. * * @param number aIndex * The position in the container intended for this group. */ - insertSelfAt: function SMG_insertSelfAt(aIndex) { + insertSelfAt: function(aIndex) { let ownerList = this.ownerView._list; let groupsArray = this._orderedGroupElementsArray; if (aIndex >= 0) { ownerList.insertBefore(this._target, groupsArray[aIndex]); groupsArray.splice(aIndex, 0, this._target); } else { ownerList.appendChild(this._target); @@ -478,17 +478,17 @@ SideMenuGroup.prototype = { }, /** * Finds the expected index of this group based on its name. * * @return number * The expected index. */ - findExpectedIndexForSelf: function SMG_findExpectedIndexForSelf() { + findExpectedIndexForSelf: function() { let identifier = this.identifier; let groupsArray = this._orderedGroupElementsArray; for (let group of groupsArray) { let name = group.getAttribute("name"); if (name > identifier && // Insertion sort at its best :) !name.contains(identifier)) { // Least significat group should be last. return groupsArray.indexOf(group); @@ -556,17 +556,17 @@ SideMenuItem.prototype = { /** * Inserts this item in the parent group at the specified index. * * @param number aIndex * The position in the container intended for this item. * @return nsIDOMNode * The element associated with the displayed item. */ - insertSelfAt: function SMI_insertSelfAt(aIndex) { + insertSelfAt: function(aIndex) { let ownerList = this.ownerView._list; let menuArray = this._orderedMenuElementsArray; if (aIndex >= 0) { ownerList.insertBefore(this._container, ownerList.childNodes[aIndex]); menuArray.splice(aIndex, 0, this._target); } else { ownerList.appendChild(this._container);
--- a/browser/devtools/shared/widgets/VariablesView.jsm +++ b/browser/devtools/shared/widgets/VariablesView.jsm @@ -92,17 +92,17 @@ VariablesView.prototype = { /** * Adds a scope to contain any inspected variables. * * @param string aName * The scope's name (e.g. "Local", "Global" etc.). * @return Scope * The newly created Scope instance. */ - addScope: function VV_addScope(aName = "") { + addScope: function(aName = "") { this._removeEmptyNotice(); this._toggleSearchVisibility(true); let scope = new Scope(this, aName); this._store.push(scope); this._itemsByElement.set(scope._target, scope); this._currHierarchy.set(aName, scope); scope.header = !!aName; @@ -111,17 +111,17 @@ VariablesView.prototype = { /** * Removes all items from this container. * * @param number aTimeout [optional] * The number of milliseconds to delay the operation if * lazy emptying of this container is enabled. */ - empty: function VV_empty(aTimeout = this.lazyEmptyDelay) { + empty: function(aTimeout = this.lazyEmptyDelay) { // If there are no items in this container, emptying is useless. if (!this._store.length) { return; } // Check if this empty operation may be executed lazily. if (this.lazyEmpty && aTimeout > 0) { this._emptySoon(aTimeout); return; @@ -150,17 +150,17 @@ VariablesView.prototype = { * immediately attached to the parent container. The old container list * is kept around for a short period of time, hopefully accounting for the * data fetching delay. In the meantime, any operations can be executed * normally. * * @see VariablesView.empty * @see VariablesView.commitHierarchy */ - _emptySoon: function VV__emptySoon(aTimeout) { + _emptySoon: function(aTimeout) { let prevList = this._list; let currList = this._list = this.document.createElement("scrollbox"); this._store.length = 0; this._itemsByElement.clear(); this._emptyTimeout = this.window.setTimeout(() => { this._emptyTimeout = null; @@ -367,17 +367,17 @@ VariablesView.prototype = { * @return string */ get searchPlaceholder() this._searchboxPlaceholder, /** * Enables variable and property searching in this view. * Use the "searchEnabled" setter to enable searching. */ - _enableSearch: function VV__enableSearch() { + _enableSearch: function() { // If searching was already enabled, no need to re-enable it again. if (this._searchboxContainer) { return; } let document = this.document; let ownerView = this._parent.parentNode; let container = this._searchboxContainer = document.createElement("hbox"); @@ -398,17 +398,17 @@ VariablesView.prototype = { container.appendChild(searchbox); ownerView.insertBefore(container, this._parent); }, /** * Disables variable and property searching in this view. * Use the "searchEnabled" setter to disable searching. */ - _disableSearch: function VV__disableSearch() { + _disableSearch: function() { // If searching was already disabled, no need to re-disable it again. if (!this._searchboxContainer) { return; } this._searchboxContainer.remove(); this._searchboxNode.removeEventListener("input", this._onSearchboxInput, false); this._searchboxNode.removeEventListener("keypress", this._onSearchboxKeyPress, false); @@ -418,35 +418,35 @@ VariablesView.prototype = { /** * Sets the variables searchbox container hidden or visible. * It's hidden by default. * * @param boolean aVisibleFlag * Specifies the intended visibility. */ - _toggleSearchVisibility: function VV__toggleSearchVisibility(aVisibleFlag) { + _toggleSearchVisibility: function(aVisibleFlag) { // If searching was already disabled, there's no need to hide it. if (!this._searchboxContainer) { return; } this._searchboxContainer.hidden = !aVisibleFlag; }, /** * Listener handling the searchbox input event. */ - _onSearchboxInput: function VV__onSearchboxInput() { + _onSearchboxInput: function() { this.performSearch(this._searchboxNode.value); }, /** * Listener handling the searchbox key press event. */ - _onSearchboxKeyPress: function VV__onSearchboxKeyPress(e) { + _onSearchboxKeyPress: function(e) { switch(e.keyCode) { case e.DOM_VK_RETURN: case e.DOM_VK_ENTER: this._onSearchboxInput(); return; case e.DOM_VK_ESCAPE: this._searchboxNode.value = ""; this._onSearchboxInput(); @@ -460,17 +460,17 @@ VariablesView.prototype = { delayedSearch: true, /** * Schedules searching for variables or properties matching the query. * * @param string aQuery * The variable or property to search for. */ - scheduleSearch: function VV_scheduleSearch(aQuery) { + scheduleSearch: function(aQuery) { if (!this.delayedSearch) { this.performSearch(aQuery); return; } let delay = Math.max(SEARCH_ACTION_MAX_DELAY / aQuery.length, 0); this.window.clearTimeout(this._searchTimeout); this._searchFunction = this._startSearch.bind(this, aQuery); @@ -478,17 +478,17 @@ VariablesView.prototype = { }, /** * Immediately searches for variables or properties matching the query. * * @param string aQuery * The variable or property to search for. */ - performSearch: function VV_performSearch(aQuery) { + performSearch: function(aQuery) { this.window.clearTimeout(this._searchTimeout); this._searchFunction = null; this._startSearch(aQuery); }, /** * Performs a case insensitive search for variables or properties matching * the query, and hides non-matched items. @@ -499,17 +499,17 @@ VariablesView.prototype = { * * If aQuery is null or undefined, then all the scopes are just unhidden, * and the available variables and properties inside those scopes are also * just unhidden. * * @param string aQuery * The variable or property to search for. */ - _startSearch: function VV__startSearch(aQuery) { + _startSearch: function(aQuery) { for (let scope of this._store) { switch (aQuery) { case "": scope.expand(); // fall through case null: case undefined: scope._performSearch(""); @@ -519,17 +519,17 @@ VariablesView.prototype = { break; } } }, /** * Expands the first search results in this container. */ - expandFirstSearchResults: function VV_expandFirstSearchResults() { + expandFirstSearchResults: function() { for (let scope of this._store) { let match = scope._firstMatch; if (match) { match.expand(); } } }, @@ -539,17 +539,17 @@ VariablesView.prototype = { * user). Descends into each scope to check the scope and its children. * * @param function aPredicate * A function that returns true when a match is found. * @return Scope | Variable | Property * The first visible scope, variable or property, or null if nothing * is found. */ - _findInVisibleItems: function VV__findInVisibleItems(aPredicate) { + _findInVisibleItems: function(aPredicate) { for (let scope of this._store) { let result = scope._findInVisibleItems(aPredicate); if (result) { return result; } } return null; }, @@ -561,44 +561,44 @@ VariablesView.prototype = { * its children. * * @param function aPredicate * A function that returns true when a match is found. * @return Scope | Variable | Property * The last visible scope, variable or property, or null if nothing * is found. */ - _findInVisibleItemsReverse: function VV__findInVisibleItemsReverse(aPredicate) { + _findInVisibleItemsReverse: function(aPredicate) { for (let i = this._store.length - 1; i >= 0; i--) { let scope = this._store[i]; let result = scope._findInVisibleItemsReverse(aPredicate); if (result) { return result; } } return null; }, /** * Focuses the first visible scope, variable, or property in this container. */ - focusFirstVisibleNode: function VV_focusFirstVisibleNode() { + focusFirstVisibleNode: function() { let focusableItem = this._findInVisibleItems(item => item.focusable); if (focusableItem) { this._focusItem(focusableItem); } this._parent.scrollTop = 0; this._parent.scrollLeft = 0; }, /** * Focuses the last visible scope, variable, or property in this container. */ - focusLastVisibleNode: function VV_focusLastVisibleNode() { + focusLastVisibleNode: function() { let focusableItem = this._findInVisibleItemsReverse(item => item.focusable); if (focusableItem) { this._focusItem(focusableItem); } this._parent.scrollTop = this._parent.scrollHeight; this._parent.scrollLeft = 0; }, @@ -606,76 +606,76 @@ VariablesView.prototype = { /** * Searches for the scope in this container displayed by the specified node. * * @param nsIDOMNode aNode * The node to search for. * @return Scope * The matched scope, or null if nothing is found. */ - getScopeForNode: function VV_getScopeForNode(aNode) { + getScopeForNode: function(aNode) { let item = this._itemsByElement.get(aNode); if (item && !(item instanceof Variable) && !(item instanceof Property)) { return item; } return null; }, /** * Recursively searches this container for the scope, variable or property * displayed by the specified node. * * @param nsIDOMNode aNode * The node to search for. * @return Scope | Variable | Property * The matched scope, variable or property, or null if nothing is found. */ - getItemForNode: function VV_getItemForNode(aNode) { + getItemForNode: function(aNode) { return this._itemsByElement.get(aNode); }, /** * Gets the currently focused scope, variable or property in this view. * * @return Scope | Variable | Property * The focused scope, variable or property, or null if nothing is found. */ - getFocusedItem: function VV_getFocusedItem() { + getFocusedItem: function() { let focused = this.document.commandDispatcher.focusedElement; return this.getItemForNode(focused); }, /** * Focuses the next scope, variable or property in this view. * @see VariablesView.prototype._focusChange */ - focusNextItem: function VV_focusNextItem(aMaintainViewFocusedFlag) { + focusNextItem: function(aMaintainViewFocusedFlag) { this._focusChange("advanceFocus", aMaintainViewFocusedFlag) }, /** * Focuses the previous scope, variable or property in this view. * @see VariablesView.prototype._focusChange */ - focusPrevItem: function VV_focusPrevItem(aMaintainViewFocusedFlag) { + focusPrevItem: function(aMaintainViewFocusedFlag) { this._focusChange("rewindFocus", aMaintainViewFocusedFlag) }, /** * Focuses the next or previous scope, variable or property in this view. * * @param string aDirection * Either "advanceFocus" or "rewindFocus". * @param boolean aMaintainViewFocusedFlag * True too keep this view focused if the element is out of bounds. * @return boolean * True if the focus went out of bounds and the first or last element * in this view was focused instead. */ - _focusChange: function VV__focusChange(aDirection, aMaintainViewFocusedFlag) { + _focusChange: function(aDirection, aMaintainViewFocusedFlag) { let commandDispatcher = this.document.commandDispatcher; let item; do { commandDispatcher[aDirection](); // If maintaining this view focused is not mandatory, a simple // "advanceFocus" or "rewindFocus" command dispatch is sufficient. @@ -706,32 +706,32 @@ VariablesView.prototype = { * * @param aItem Scope | Variable | Property * The item to focus. * @param boolean aCollapseFlag * True if the focused item should also be collapsed. * @return boolean * True if the item was successfully focused. */ - _focusItem: function VV__focusItem(aItem, aCollapseFlag) { + _focusItem: function(aItem, aCollapseFlag) { if (!aItem.focusable) { return false; } if (aCollapseFlag) { aItem.collapse(); } aItem._target.focus(); this._boxObject.ensureElementIsVisible(aItem._arrow); return true; }, /** * Listener handling a key press event on the view. */ - _onViewKeyPress: function VV__onViewKeyPress(e) { + _onViewKeyPress: function(e) { let item = this.getFocusedItem(); switch (e.keyCode) { case e.DOM_VK_UP: case e.DOM_VK_DOWN: case e.DOM_VK_LEFT: case e.DOM_VK_RIGHT: case e.DOM_VK_PAGE_UP: @@ -851,33 +851,33 @@ VariablesView.prototype = { } this._emptyTextValue = aValue; this._appendEmptyNotice(); }, /** * Creates and appends a label signaling that this container is empty. */ - _appendEmptyNotice: function VV__appendEmptyNotice() { + _appendEmptyNotice: function() { if (this._emptyTextNode || !this._emptyTextValue) { return; } let label = this.document.createElement("label"); label.className = "variables-view-empty-notice"; label.setAttribute("value", this._emptyTextValue); this._parent.appendChild(label); this._emptyTextNode = label; }, /** * Removes the label signaling that this container is empty. */ - _removeEmptyNotice: function VV__removeEmptyNotice() { + _removeEmptyNotice: function() { if (!this._emptyTextNode) { return; } this._parent.removeChild(this._emptyTextNode); this._emptyTextNode = null; }, @@ -1121,17 +1121,17 @@ Scope.prototype = { * - { value: { type: "object", class: "Object" } } * - { get: { type: "object", class: "Function" }, * set: { type: "undefined" } } * @param boolean aRelaxed * True if name duplicates should be allowed. * @return Variable * The newly created Variable instance, null if it already exists. */ - addVar: function S_addVar(aName = "", aDescriptor = {}, aRelaxed = false) { + addVar: function(aName = "", aDescriptor = {}, aRelaxed = false) { if (this._store.has(aName) && !aRelaxed) { return null; } let variable = new Variable(this, aName, aDescriptor); this._store.set(aName, variable); this._variablesView._itemsByElement.set(variable._target, variable); this._variablesView._currHierarchy.set(variable._absoluteName, variable); @@ -1142,30 +1142,30 @@ Scope.prototype = { /** * Gets the variable in this container having the specified name. * * @param string aName * The name of the variable to get. * @return Variable * The matched variable, or null if nothing is found. */ - get: function S_get(aName) { + get: function(aName) { return this._store.get(aName); }, /** * Recursively searches for the variable or property in this container * displayed by the specified node. * * @param nsIDOMNode aNode * The node to search for. * @return Variable | Property * The matched variable or property, or null if nothing is found. */ - find: function S_find(aNode) { + find: function(aNode) { for (let [, variable] of this._store) { let match; if (variable._target == aNode) { match = variable; } else { match = variable.find(aNode); } if (match) { @@ -1179,68 +1179,68 @@ Scope.prototype = { * Determines if this scope is a direct child of a parent variables view, * scope, variable or property. * * @param VariablesView | Scope | Variable | Property * The parent to check. * @return boolean * True if the specified item is a direct child, false otherwise. */ - isChildOf: function S_isChildOf(aParent) { + isChildOf: function(aParent) { return this.ownerView == aParent; }, /** * Determines if this scope is a descendant of a parent variables view, * scope, variable or property. * * @param VariablesView | Scope | Variable | Property * The parent to check. * @return boolean * True if the specified item is a descendant, false otherwise. */ - isDescendantOf: function S_isDescendantOf(aParent) { + isDescendantOf: function(aParent) { if (this.isChildOf(aParent)) { return true; } if (this.ownerView instanceof Scope || this.ownerView instanceof Variable || this.ownerView instanceof Property) { return this.ownerView.isDescendantOf(aParent); } }, /** * Shows the scope. */ - show: function S_show() { + show: function() { this._target.hidden = false; this._isContentVisible = true; if (this.onshow) { this.onshow(this); } }, /** * Hides the scope. */ - hide: function S_hide() { + hide: function() { this._target.hidden = true; this._isContentVisible = false; if (this.onhide) { this.onhide(this); } }, /** * Expands the scope, showing all the added details. */ - expand: function S_expand() { + expand: function() { if (this._isExpanded || this._locked) { return; } // If there's a large number of enumerable or non-enumerable items // contained in this scope, painting them may take several seconds, // even if they were already displayed before. In this case, show a throbber // to suggest that this scope is expanding. if (!this._isExpanding && @@ -1267,34 +1267,34 @@ Scope.prototype = { if (this.onexpand) { this.onexpand(this); } }, /** * Collapses the scope, hiding all the added details. */ - collapse: function S_collapse() { + collapse: function() { if (!this._isExpanded || this._locked) { return; } this._arrow.removeAttribute("open"); this._enum.removeAttribute("open"); this._nonenum.removeAttribute("open"); this._isExpanded = false; if (this.oncollapse) { this.oncollapse(this); } }, /** * Toggles between the scope's collapsed and expanded state. */ - toggle: function S_toggle(e) { + toggle: function(e) { if (e && e.button != 0) { // Only allow left-click to trigger this event. return; } this._wasToggled = true; this.expanded ^= 1; // Make sure the scope and its contents are visibile. @@ -1305,52 +1305,52 @@ Scope.prototype = { if (this.ontoggle) { this.ontoggle(this); } }, /** * Shows the scope's title header. */ - showHeader: function S_showHeader() { + showHeader: function() { if (this._isHeaderVisible || !this._nameString) { return; } this._target.removeAttribute("non-header"); this._isHeaderVisible = true; }, /** * Hides the scope's title header. * This action will automatically expand the scope. */ - hideHeader: function S_hideHeader() { + hideHeader: function() { if (!this._isHeaderVisible) { return; } this.expand(); this._target.setAttribute("non-header", ""); this._isHeaderVisible = false; }, /** * Shows the scope's expand/collapse arrow. */ - showArrow: function S_showArrow() { + showArrow: function() { if (this._isArrowVisible) { return; } this._arrow.removeAttribute("invisible"); this._isArrowVisible = true; }, /** * Hides the scope's expand/collapse arrow. */ - hideArrow: function S_hideArrow() { + hideArrow: function() { if (!this._isArrowVisible) { return; } this._arrow.setAttribute("invisible", ""); this._isArrowVisible = false; }, /** @@ -1436,37 +1436,37 @@ Scope.prototype = { } } return true; }, /** * Focus this scope. */ - focus: function S_focus() { + focus: function() { this._variablesView._focusItem(this); }, /** * Adds an event listener for a certain event on this scope's title. * @param string aName * @param function aCallback * @param boolean aCapture */ - addEventListener: function S_addEventListener(aName, aCallback, aCapture) { + addEventListener: function(aName, aCallback, aCapture) { this._title.addEventListener(aName, aCallback, aCapture); }, /** * Removes an event listener for a certain event on this scope's title. * @param string aName * @param function aCallback * @param boolean aCapture */ - removeEventListener: function S_removeEventListener(aName, aCallback, aCapture) { + removeEventListener: function(aName, aCallback, aCapture) { this._title.removeEventListener(aName, aCallback, aCapture); }, /** * Gets the id associated with this item. * @return string */ get id() this._idString, @@ -1498,34 +1498,34 @@ Scope.prototype = { /** * Initializes this scope's id, view and binds event listeners. * * @param string aName * The scope's name. * @param object aFlags [optional] * Additional options or flags for this scope. */ - _init: function S__init(aName, aFlags) { + _init: function(aName, aFlags) { this._idString = generateId(this._nameString = aName); this._displayScope(aName, "variables-view-scope", "devtools-toolbar"); this._addEventListeners(); this.parentNode.appendChild(this._target); }, /** * Creates the necessary nodes for this scope. * * @param string aName * The scope's name. * @param string aClassName * A custom class name for this scope. * @param string aTitleClassName [optional] * A custom class name for this scope's title. */ - _displayScope: function S__createScope(aName, aClassName, aTitleClassName) { + _displayScope: function(aName, aClassName, aTitleClassName) { let document = this.document; let element = this._target = document.createElement("vbox"); element.id = this._idString; element.className = aClassName; let arrow = this._arrow = document.createElement("hbox"); arrow.className = "arrow"; @@ -1549,24 +1549,24 @@ Scope.prototype = { element.appendChild(title); element.appendChild(enumerable); element.appendChild(nonenum); }, /** * Adds the necessary event listeners for this scope. */ - _addEventListeners: function S__addEventListeners() { + _addEventListeners: function() { this._title.addEventListener("mousedown", this._onClick, false); }, /** * The click listener for this scope's title. */ - _onClick: function S__onClick(e) { + _onClick: function(e) { if (e.target == this._inputNode || e.target == this._editNode || e.target == this._deleteNode) { return; } this.toggle(); this.focus(); }, @@ -1579,17 +1579,17 @@ Scope.prototype = { * @param boolean aImmediateFlag * Set to false if append calls should be dispatched synchronously * on the current thread, to allow for a paint flush. * @param boolean aEnumerableFlag * Specifies if the node to append is enumerable or non-enumerable. * @param nsIDOMNode aChild * The child node to append. */ - _lazyAppend: function S__lazyAppend(aImmediateFlag, aEnumerableFlag, aChild) { + _lazyAppend: function(aImmediateFlag, aEnumerableFlag, aChild) { // Append immediately, don't stage items and don't allow for a paint flush. if (aImmediateFlag || !this._variablesView.lazyAppend) { if (aEnumerableFlag) { this._enum.appendChild(aChild); } else { this._nonenum.appendChild(aChild); } return; @@ -1612,17 +1612,17 @@ Scope.prototype = { // more nodes. this._batchTimeout = window.setTimeout(this._batchAppend, LAZY_APPEND_DELAY); }, /** * Appends all the batched nodes to this scope's enumerable and non-enumerable * containers. */ - _batchAppend: function S__batchAppend() { + _batchAppend: function() { let document = this.document; let batchItems = this._batchItems; // Create two document fragments, one for enumerable nodes, and one // for non-enumerable nodes. let frags = [document.createDocumentFragment(), document.createDocumentFragment()]; for (let item of batchItems) { @@ -1631,49 +1631,49 @@ Scope.prototype = { batchItems.length = 0; this._enum.appendChild(frags[1]); this._nonenum.appendChild(frags[0]); }, /** * Starts spinning a throbber in this scope's title. */ - _startThrobber: function S__startThrobber() { + _startThrobber: function() { if (this._throbber) { this._throbber.hidden = false; return; } let throbber = this._throbber = this.document.createElement("hbox"); throbber.className = "variables-view-throbber"; this._title.appendChild(throbber); }, /** * Stops spinning the throbber in this scope's title. */ - _stopThrobber: function S__stopThrobber() { + _stopThrobber: function() { if (!this._throbber) { return; } this._throbber.hidden = true; }, /** * Opens the enumerable items container. */ - _openEnum: function S__openEnum() { + _openEnum: function() { this._arrow.setAttribute("open", ""); this._enum.setAttribute("open", ""); this._stopThrobber(); }, /** * Opens the non-enumerable items container. */ - _openNonEnum: function S__openNonEnum() { + _openNonEnum: function() { this._nonenum.setAttribute("open", ""); this._stopThrobber(); }, /** * Specifies if enumerable properties and variables should be displayed. * @param boolean aFlag */ @@ -1713,17 +1713,17 @@ Scope.prototype = { /** * Performs a case insensitive search for variables or properties matching * the query, and hides non-matched items. * * @param string aLowerCaseQuery * The lowercased name of the variable or property to search for. */ - _performSearch: function S__performSearch(aLowerCaseQuery) { + _performSearch: function(aLowerCaseQuery) { for (let [, variable] of this._store) { let currentObject = variable; let lowerCaseName = variable._nameString.toLowerCase(); let lowerCaseValue = variable._valueString.toLowerCase(); // Non-matched variables or properties require a corresponding attribute. if (!lowerCaseName.contains(aLowerCaseQuery) && !lowerCaseValue.contains(aLowerCaseQuery)) { @@ -1811,17 +1811,17 @@ Scope.prototype = { * the non-enumerable children (since they are presented in separate groups). * * @param function aPredicate * A function that returns true when a match is found. * @return Scope | Variable | Property * The first visible scope, variable or property, or null if nothing * is found. */ - _findInVisibleItems: function S__findInVisibleItems(aPredicate) { + _findInVisibleItems: function(aPredicate) { if (aPredicate(this)) { return this; } if (this._isExpanded) { if (this._variablesView._enumVisible) {