michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /** michael@0: * Test for Bug 646224. Make sure that after changing the URI via michael@0: * history.pushState, the history service has a title stored for the new URI. michael@0: **/ michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: let tab = gBrowser.addTab('http://example.com'); michael@0: let tabBrowser = tab.linkedBrowser; michael@0: michael@0: tabBrowser.addEventListener('load', function(aEvent) { michael@0: tabBrowser.removeEventListener('load', arguments.callee, true); michael@0: michael@0: // Control should now flow down to observer.onTitleChanged(). michael@0: let cw = tabBrowser.contentWindow; michael@0: ok(cw.document.title, 'Content window should initially have a title.'); michael@0: cw.history.pushState('', '', 'new_page'); michael@0: }, true); michael@0: michael@0: let observer = { michael@0: onTitleChanged: function(uri, title) { michael@0: // If the uri of the page whose title is changing ends with 'new_page', michael@0: // then it's the result of our pushState. michael@0: if (/new_page$/.test(uri.spec)) { michael@0: is(title, tabBrowser.contentWindow.document.title, michael@0: 'Title after pushstate.'); michael@0: PlacesUtils.history.removeObserver(this); michael@0: gBrowser.removeTab(tab); michael@0: finish(); michael@0: } michael@0: }, michael@0: michael@0: onBeginUpdateBatch: function() { }, michael@0: onEndUpdateBatch: function() { }, michael@0: onVisit: function() { }, michael@0: onDeleteURI: function() { }, michael@0: onClearHistory: function() { }, michael@0: onPageChanged: function() { }, michael@0: onDeleteVisits: function() { }, michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver]) michael@0: }; michael@0: michael@0: PlacesUtils.history.addObserver(observer, false); michael@0: }