toolkit/components/places/tests/browser/browser_bug646422.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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 }

mercurial