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