Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /**
6 * Test for Bug 646224. Make sure that after changing the URI via
7 * history.pushState, the history service has a title stored for the new URI.
8 **/
10 function test() {
11 waitForExplicitFinish();
13 let tab = gBrowser.addTab('http://example.com');
14 let tabBrowser = tab.linkedBrowser;
16 tabBrowser.addEventListener('load', function(aEvent) {
17 tabBrowser.removeEventListener('load', arguments.callee, true);
19 // Control should now flow down to observer.onTitleChanged().
20 let cw = tabBrowser.contentWindow;
21 ok(cw.document.title, 'Content window should initially have a title.');
22 cw.history.pushState('', '', 'new_page');
23 }, true);
25 let observer = {
26 onTitleChanged: function(uri, title) {
27 // If the uri of the page whose title is changing ends with 'new_page',
28 // then it's the result of our pushState.
29 if (/new_page$/.test(uri.spec)) {
30 is(title, tabBrowser.contentWindow.document.title,
31 'Title after pushstate.');
32 PlacesUtils.history.removeObserver(this);
33 gBrowser.removeTab(tab);
34 finish();
35 }
36 },
38 onBeginUpdateBatch: function() { },
39 onEndUpdateBatch: function() { },
40 onVisit: function() { },
41 onDeleteURI: function() { },
42 onClearHistory: function() { },
43 onPageChanged: function() { },
44 onDeleteVisits: function() { },
45 QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver])
46 };
48 PlacesUtils.history.addObserver(observer, false);
49 }