author | Neil Deakin <neil@mozilla.com> |
Wed, 20 Jan 2016 08:45:58 -0500 | |
changeset 280644 | dd033af22d121e2ce58242e75ebaea4b4574b0b9 |
parent 280643 | 6f5d184b3b4259832374bd86bd84cee1a4a7186a |
child 280645 | 607774de446ffa77592d6770a51fa7e2ff2a794f |
push id | 70550 |
push user | neil@mozilla.com |
push date | Wed, 20 Jan 2016 13:46:31 +0000 |
treeherder | mozilla-inbound@7fb5dbb033ea [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mak |
bugs | 1236554 |
milestone | 46.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/toolkit/components/places/tests/browser/browser.ini +++ b/toolkit/components/places/tests/browser/browser.ini @@ -1,10 +1,9 @@ [DEFAULT] -skip-if = e10s support-files = colorAnalyzer/category-discover.png colorAnalyzer/dictionaryGeneric-16.png colorAnalyzer/extensionGeneric-16.png colorAnalyzer/localeGeneric.png head.js [browser_bug248970.js]
--- a/toolkit/components/places/tests/browser/browser_settitle.js +++ b/toolkit/components/places/tests/browser/browser_settitle.js @@ -1,36 +1,13 @@ /** * Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ -gBrowser.selectedTab = gBrowser.addTab(); - -function finishAndCleanUp() -{ - gBrowser.removeCurrentTab(); - PlacesTestUtils.clearHistory().then(finish); -} - -/** - * One-time DOMContentLoaded callback. - */ -function load(href, callback) -{ - content.location.href = href; - gBrowser.addEventListener("load", function() { - if (content.location.href == href) { - gBrowser.removeEventListener("load", arguments.callee, true); - if (callback) - callback(); - } - }, true); -} - var conn = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase).DBConnection; /** * Gets a single column value from either the places or historyvisits table. */ function getColumn(table, column, fromColumnName, fromColumnValue) { var stmt = conn.createStatement( @@ -41,60 +18,65 @@ function getColumn(table, column, fromCo stmt.executeStep(); return stmt.row[column]; } finally { stmt.finalize(); } } -function test() +add_task(function* () { // Make sure titles are correctly saved for a URI with the proper // notifications. - waitForExplicitFinish(); - // Create and add history observer. - var historyObserver = { - data: [], - onBeginUpdateBatch: function() {}, - onEndUpdateBatch: function() {}, - onVisit: function(aURI, aVisitID, aTime, aSessionID, aReferringID, - aTransitionType) { - }, - onTitleChanged: function(aURI, aPageTitle, aGUID) { - this.data.push({ uri: aURI, title: aPageTitle, guid: aGUID }); + let titleChangedPromise = new Promise(resolve => { + var historyObserver = { + data: [], + onBeginUpdateBatch: function() {}, + onEndUpdateBatch: function() {}, + onVisit: function(aURI, aVisitID, aTime, aSessionID, aReferringID, + aTransitionType) { + }, + onTitleChanged: function(aURI, aPageTitle, aGUID) { + this.data.push({ uri: aURI, title: aPageTitle, guid: aGUID }); - // We only expect one title change. - // - // Although we are loading two different pages, the first page does not - // have a title. Since the title starts out as empty and then is set - // to empty, there is no title change notification. + // We only expect one title change. + // + // Although we are loading two different pages, the first page does not + // have a title. Since the title starts out as empty and then is set + // to empty, there is no title change notification. - PlacesUtils.history.removeObserver(this); - confirmResults(this.data); - }, - onDeleteURI: function() {}, - onClearHistory: function() {}, - onPageChanged: function() {}, - onDeleteVisits: function() {}, - QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver]) - }; - PlacesUtils.history.addObserver(historyObserver, false); - - load("http://example.com/tests/toolkit/components/places/tests/browser/title1.html", function() { - load("http://example.com/tests/toolkit/components/places/tests/browser/title2.html"); + PlacesUtils.history.removeObserver(this); + resolve(this.data); + }, + onDeleteURI: function() {}, + onClearHistory: function() {}, + onPageChanged: function() {}, + onDeleteVisits: function() {}, + QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver]) + }; + PlacesUtils.history.addObserver(historyObserver, false); }); - function confirmResults(data) { - is(data[0].uri.spec, "http://example.com/tests/toolkit/components/places/tests/browser/title2.html"); - is(data[0].title, "Some title"); - is(data[0].guid, getColumn("moz_places", "guid", "url", data[0].uri.spec)); + const url1 = "http://example.com/tests/toolkit/components/places/tests/browser/title1.html"; + yield BrowserTestUtils.openNewForegroundTab(gBrowser, url1); + + const url2 = "http://example.com/tests/toolkit/components/places/tests/browser/title2.html"; + let loadPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); + BrowserTestUtils.loadURI(gBrowser.selectedBrowser, url2); + yield loadPromise; - data.forEach(function(item) { - var title = getColumn("moz_places", "title", "url", data[0].uri.spec); - is(title, item.title); - }); + let data = yield titleChangedPromise; + is(data[0].uri.spec, "http://example.com/tests/toolkit/components/places/tests/browser/title2.html"); + is(data[0].title, "Some title"); + is(data[0].guid, getColumn("moz_places", "guid", "url", data[0].uri.spec)); - finishAndCleanUp(); - } -} + data.forEach(function(item) { + var title = getColumn("moz_places", "title", "url", data[0].uri.spec); + is(title, item.title); + }); + + gBrowser.removeCurrentTab(); + yield PlacesTestUtils.clearHistory(); +}); +