Bug 1423896 - Rewrite browser_library_panel_leak.js to use async & await. r=mak
authorMark Banner <standard8@mozilla.com>
Mon, 08 Jan 2018 17:27:41 +0000
changeset 402795 f2d20b78861e2502159a77ce3b0f9800c98fa9aa
parent 402794 2211efa3ab47fb129834953439d743bb5a89f524
child 402796 32ec5531af09ef18512b09ea0a4e2b5240e7c236
push id99659
push useraciure@mozilla.com
push dateWed, 07 Feb 2018 22:33:57 +0000
treeherdermozilla-inbound@5ceb1098fef3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1423896
milestone60.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
Bug 1423896 - Rewrite browser_library_panel_leak.js to use async & await. r=mak MozReview-Commit-ID: 4HuGbt814i0
browser/components/places/tests/browser/browser_library_panel_leak.js
--- a/browser/components/places/tests/browser/browser_library_panel_leak.js
+++ b/browser/components/places/tests/browser/browser_library_panel_leak.js
@@ -7,48 +7,42 @@
 /**
  *  Bug 433231 - Places Library leaks the nsGlobalWindow when closed with a
  *               history entry selected.
  * https://bugzilla.mozilla.org/show_bug.cgi?id=433231
  *
  * STRs: Open Library, select an history entry in History, close Library.
  * ISSUE: We were adding a bookmarks observer when editing a bookmark, when
  *        selecting an history entry the panel was not un-initialized, and
- *        since an histroy entry does not have an itemId, the observer was
+ *        since an history entry does not have an itemId, the observer was
  *        never removed.
  */
 
 const TEST_URI = "http://www.mozilla.org/";
 
-function test() {
-  function onLibraryReady(organizer) {
-    let contentTree = organizer.document.getElementById("placeContent");
-    isnot(contentTree, null, "Sanity check: placeContent tree should exist");
-    isnot(organizer.PlacesOrganizer, null, "Sanity check: PlacesOrganizer should exist");
-    isnot(organizer.gEditItemOverlay, null, "Sanity check: gEditItemOverlay should exist");
+add_task(async function test_no_leak_closing_library_with_history_selected() {
+  // Add an history entry.
+  await PlacesTestUtils.addVisits(TEST_URI);
+
+  let organizer = await promiseLibrary();
 
-    ok(organizer.gEditItemOverlay.initialized, "gEditItemOverlay is initialized");
-    isnot(organizer.gEditItemOverlay.itemId, -1, "Editing a bookmark");
+  let contentTree = organizer.document.getElementById("placeContent");
+  Assert.notEqual(contentTree, null, "Sanity check: placeContent tree should exist");
+  Assert.notEqual(organizer.PlacesOrganizer, null, "Sanity check: PlacesOrganizer should exist");
+  Assert.notEqual(organizer.gEditItemOverlay, null, "Sanity check: gEditItemOverlay should exist");
+
+  Assert.ok(organizer.gEditItemOverlay.initialized, "gEditItemOverlay is initialized");
+  Assert.notEqual(organizer.gEditItemOverlay._paneInfo.itemGuid, "", "Editing a bookmark");
 
-    // Select History in the left pane.
-    organizer.PlacesOrganizer.selectLeftPaneBuiltIn("History");
-    // Select the first history entry.
-    let selection = contentTree.view.selection;
-    selection.clearSelection();
-    selection.rangedSelect(0, 0, true);
-    // Check the panel is editing the history entry.
-    is(organizer.gEditItemOverlay.itemId, -1, "Editing an history entry");
-    // Close Library window.
-    organizer.close();
-    // Clean up history.
-    PlacesTestUtils.clearHistory().then(finish);
-  }
+  // Select History in the left pane.
+  organizer.PlacesOrganizer.selectLeftPaneBuiltIn("History");
+  // Select the first history entry.
+  let selection = contentTree.view.selection;
+  selection.clearSelection();
+  selection.rangedSelect(0, 0, true);
+  // Check the panel is editing the history entry.
+  Assert.equal(organizer.gEditItemOverlay._paneInfo.itemGuid, "", "Editing an history entry");
+  // Close Library window.
+  organizer.close();
 
-  waitForExplicitFinish();
-  // Add an history entry.
-  ok(PlacesUtils, "checking PlacesUtils, running in chrome context?");
-  PlacesTestUtils.addVisits(
-    {uri: Services.io.newURI(TEST_URI), visitDate: Date.now() * 1000,
-      transition: PlacesUtils.history.TRANSITION_TYPED}
-    ).then(() => {
-      openLibrary(onLibraryReady);
-    });
-}
+  // Clean up history.
+  await PlacesUtils.history.clear();
+});