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