diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /toolkit/components/places/tests/browser/browser_settitle.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/places/tests/browser/browser_settitle.js')
-rw-r--r-- | toolkit/components/places/tests/browser/browser_settitle.js | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/toolkit/components/places/tests/browser/browser_settitle.js b/toolkit/components/places/tests/browser/browser_settitle.js new file mode 100644 index 000000000..68c8deda7 --- /dev/null +++ b/toolkit/components/places/tests/browser/browser_settitle.js @@ -0,0 +1,76 @@ +var conn = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase).DBConnection; + +/** + * Gets a single column value from either the places or historyvisits table. + */ +function getColumn(table, column, url) +{ + var stmt = conn.createStatement( + `SELECT ${column} FROM ${table} WHERE url_hash = hash(:val) AND url = :val`); + try { + stmt.params.val = url; + stmt.executeStep(); + return stmt.row[column]; + } + finally { + stmt.finalize(); + } +} + +add_task(function* () +{ + // Make sure titles are correctly saved for a URI with the proper + // notifications. + + // Create and add history observer. + 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. + + 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); + }); + + 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; + + 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", data[0].uri.spec)); + + data.forEach(function(item) { + var title = getColumn("moz_places", "title", data[0].uri.spec); + is(title, item.title); + }); + + gBrowser.removeCurrentTab(); + yield PlacesTestUtils.clearHistory(); +}); + |