Bug 898120 - Fix leak of global variable in Metro selection code [r=jimm]
authorMatt Brubeck <mbrubeck@mozilla.com>
Fri, 26 Jul 2013 14:34:02 -0700
changeset 140241 7c02ec2b89883536305b1de12d8a1c0cf25cdfc5
parent 140240 be0befd009cb1b598531025b16f3ee375ee46655
child 140242 bf035bca7f6529bdc298449646fcf6f09549f3fe
push id1951
push userryanvm@gmail.com
push dateSun, 28 Jul 2013 01:55:51 +0000
treeherderfx-team@73b69c146ca6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs898120
milestone25.0a1
Bug 898120 - Fix leak of global variable in Metro selection code [r=jimm]
browser/metro/base/content/library/SelectionPrototype.js
browser/metro/base/tests/mochitest/browser_selection_urlbar.js
browser/metro/base/tests/mochitest/browser_urlbar.js
--- a/browser/metro/base/content/library/SelectionPrototype.js
+++ b/browser/metro/base/content/library/SelectionPrototype.js
@@ -1,11 +1,12 @@
 /* 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";
 
 /*
  * SelectionPrototype - common base class used by both chrome and content selection logic.
  */
 
 // selection node parameters for various apis
 const kSelectionNodeAnchor = 1;
 const kSelectionNodeFocus = 2;
@@ -771,17 +772,17 @@ SelectionPrototype.prototype = {
       let r = aRange.getBoundingClientRect();
       seldata.selection.left = r.left + this._contentOffset.x;
       seldata.selection.top = r.top + this._contentOffset.y;
       seldata.selection.right = r.right + this._contentOffset.x;
       seldata.selection.bottom = r.bottom + this._contentOffset.y;
     }
 
     // Store the client rect of target element
-    r = this._getTargetClientRect();
+    let r = this._getTargetClientRect();
     seldata.element.left = r.left + this._contentOffset.x;
     seldata.element.top = r.top + this._contentOffset.y;
     seldata.element.right = r.right + this._contentOffset.x;
     seldata.element.bottom = r.bottom + this._contentOffset.y;
 
     // If we don't have a range we can attach to let SelectionHelperUI know.
     seldata.selectionRangeFound = !!rects.length;
 
--- a/browser/metro/base/tests/mochitest/browser_selection_urlbar.js
+++ b/browser/metro/base/tests/mochitest/browser_selection_urlbar.js
@@ -58,19 +58,16 @@ gTests.push({
     yield waitForCondition(function () {
       return getTrimmedSelection(edit).toString() ==
         "mochitests/content/metro/browser/metro/base/tests/mochitest/res/textblock01.html";
     }, kCommonWaitMs, kCommonPollMs);
     touchdrag.end();
     yield waitForMs(100);
 
     ok(SelectionHelperUI.isSelectionUIVisible, "selection ui active");
-
-    // taps on the urlbar-edit leak a ClientRect property on the window
-    delete window.r;
   },
 });
 
 gTests.push({
   desc: "bug 887120 - tap & hold to paste into urlbar",
   run: function() {
     gWindow = window;
 
@@ -84,17 +81,16 @@ gTests.push({
     ok(ContextMenuUI._menuPopup._visible, "is visible");
     let paste = document.getElementById("context-paste");
     ok(!paste.hidden, "paste item is visible");
 
     sendElementTap(window, paste);
     ok(edit.popup.popupOpen, "bug: popup should be showing");
 
     clearSelection(edit);
-    delete window.r;
   }
 });
 
 gTests.push({
   desc: "bug 895284 - tap selection",
   run: function() {
     gWindow = window;
 
@@ -114,34 +110,32 @@ gTests.push({
     let midX = Math.ceil(((rects[0].right - rects[0].left) * .5) + rects[0].left);
     let midY = Math.ceil(((rects[0].bottom - rects[0].top) * .5) + rects[0].top);
 
     sendTap(window, midX, midY);
 
     ok(SelectionHelperUI.isCaretUIVisible, "caret browsing enabled");
 
     clearSelection(edit);
-    delete window.r;
   }
 });
 
 gTests.push({
   desc: "bug 894713 - blur shuts down selection handling",
   run: function() {
     gWindow = window;
     yield showNavBar();
     let edit = document.getElementById("urlbar-edit");
     edit.value = "wikipedia.org";
     edit.select();
     let editCoords = logicalCoordsForElement(edit);
     SelectionHelperUI.attachEditSession(ChromeSelectionHandler, editCoords.x, editCoords.y);
     edit.blur();
     ok(!SelectionHelperUI.isSelectionUIVisible, "selection no longer enabled");
     clearSelection(edit);
-    delete window.r;
   }
 });
 
 function test() {
   if (!isLandscapeMode()) {
     todo(false, "browser_selection_tests need landscape mode to run.");
     return;
   }
--- a/browser/metro/base/tests/mochitest/browser_urlbar.js
+++ b/browser/metro/base/tests/mochitest/browser_urlbar.js
@@ -104,17 +104,16 @@ function setUp() {
   yield waitForCondition(function () {
     return StartUI.isStartPageVisible;
   });
 }
 
 function tearDown() {
   yield removeMockSearchDefault();
   Browser.closeTab(Browser.selectedTab, { forceClose: true });
-  delete window.r;
 }
 
 gTests.push({
   desc: "search engines update",
   setUp: setUp,
   tearDown: tearDown,
   run: function testSearchEngine() {
     // If the XBL hasn't initialized yet, open the popup so that it will.