docshell/test/browser/browser_bug655270.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 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 /**
michael@0 5 * Test for Bug 655273
michael@0 6 *
michael@0 7 * Call pushState and then make sure that the favicon service associates our
michael@0 8 * old favicon with the new URI.
michael@0 9 */
michael@0 10
michael@0 11 function test() {
michael@0 12 const testDir = "http://mochi.test:8888/browser/docshell/test/browser/";
michael@0 13 const origURL = testDir + "file_bug655270.html";
michael@0 14 const newURL = origURL + '?new_page';
michael@0 15
michael@0 16 const faviconURL = testDir + "favicon_bug655270.ico";
michael@0 17
michael@0 18 waitForExplicitFinish();
michael@0 19
michael@0 20 let tab = gBrowser.addTab(origURL);
michael@0 21
michael@0 22 // The page at origURL has a <link rel='icon'>, so we should get a call into
michael@0 23 // our observer below when it loads. Once we verify that we have the right
michael@0 24 // favicon URI, we call pushState, which should trigger another onPageChange
michael@0 25 // event, this time for the URI after pushState.
michael@0 26
michael@0 27 let observer = {
michael@0 28 onPageChanged: function(aURI, aWhat, aValue) {
michael@0 29 if (aWhat != Ci.nsINavHistoryObserver.ATTRIBUTE_FAVICON)
michael@0 30 return;
michael@0 31
michael@0 32 if (aURI.spec == origURL) {
michael@0 33 is(aValue, faviconURL, 'FaviconURL for original URI');
michael@0 34 tab.linkedBrowser.contentWindow.history.pushState('', '', '?new_page');
michael@0 35 }
michael@0 36
michael@0 37 if (aURI.spec == newURL) {
michael@0 38 is(aValue, faviconURL, 'FaviconURL for new URI');
michael@0 39 gBrowser.removeTab(tab);
michael@0 40 PlacesUtils.history.removeObserver(this);
michael@0 41 finish();
michael@0 42 }
michael@0 43 },
michael@0 44
michael@0 45 onBeginUpdateBatch: function() { },
michael@0 46 onEndUpdateBatch: function() { },
michael@0 47 onVisit: function() { },
michael@0 48 onTitleChanged: function() { },
michael@0 49 onDeleteURI: function() { },
michael@0 50 onClearHistory: function() { },
michael@0 51 onDeleteVisits: function() { },
michael@0 52 QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver])
michael@0 53 };
michael@0 54
michael@0 55 PlacesUtils.history.addObserver(observer, false);
michael@0 56 }

mercurial