mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 503832. Visiting a new fragmentid (scrolling to named anchor) should set the title of the page in the global history for the url with that anchor. r=bzbarsky
This commit is contained in:
parent
4897e14595
commit
8004b896f5
@ -7943,7 +7943,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
if (mOSHE) {
|
||||
mOSHE->GetOwner(getter_AddRefs(owner));
|
||||
}
|
||||
OnNewURI(aURI, nsnull, owner, mLoadType, PR_TRUE);
|
||||
OnNewURI(aURI, nsnull, owner, mLoadType, PR_TRUE, PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsIInputStream> postData;
|
||||
PRUint32 pageIdent = PR_UINT32_MAX;
|
||||
@ -8028,6 +8028,12 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
shEntry->SetTitle(mTitle);
|
||||
}
|
||||
|
||||
/* Set the title for the Global History entry for this anchor url.
|
||||
*/
|
||||
if (mGlobalHistory) {
|
||||
mGlobalHistory->SetPageTitle(aURI, mTitle);
|
||||
}
|
||||
|
||||
if (sameDocIdent) {
|
||||
// Set the doc's URI according to the new history entry's URI
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
|
@ -48,6 +48,8 @@ _BROWSER_TEST_FILES = \
|
||||
browser_bug388121-1.js \
|
||||
browser_bug388121-2.js \
|
||||
browser_bug441169.js \
|
||||
browser_bug503832.js \
|
||||
file_bug503832.html \
|
||||
$(NULL)
|
||||
|
||||
# the tests below use FUEL, which is a Firefox-specific feature
|
||||
|
97
docshell/test/browser/browser_bug503832.js
Normal file
97
docshell/test/browser/browser_bug503832.js
Normal file
@ -0,0 +1,97 @@
|
||||
/* Test for Bug 503832
|
||||
* https://bugzilla.mozilla.org/show_bug.cgi?id=503832
|
||||
*/
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
var pagetitle = "Page Title for Bug 503832";
|
||||
var pageurl = "http://localhost:8888/browser/docshell/test/browser/file_bug503832.html";
|
||||
var fragmenturl = "http://localhost:8888/browser/docshell/test/browser/file_bug503832.html#firefox";
|
||||
|
||||
/* Global history observer that triggers for the two test URLs above. */
|
||||
var historyObserver = {
|
||||
onBeginUpdateBatch: function() {},
|
||||
onEndUpdateBatch: function() {},
|
||||
onVisit: function(aURI, aVisitID, aTime, aSessionId, aReferringId,
|
||||
aTransitionType, _added) {},
|
||||
onTitleChanged: function(aURI, aPageTitle) {
|
||||
aURI = aURI.spec;
|
||||
switch (aURI) {
|
||||
case pageurl:
|
||||
is(aPageTitle, pagetitle, "Correct page title for " + aURI);
|
||||
return;
|
||||
case fragmenturl:
|
||||
is(aPageTitle, pagetitle, "Correct page title for " + aURI);
|
||||
// If titles for fragment URLs aren't set, this code
|
||||
// branch won't be called and the test will timeout,
|
||||
// resulting in a failure
|
||||
finish();
|
||||
}
|
||||
},
|
||||
onBeforeDeleteURI: function(aURI) {},
|
||||
onDeleteURI: function(aURI) {},
|
||||
onClearHistory: function() {},
|
||||
onPageChanged: function(aURI, aWhat, aValue) {},
|
||||
onPageExpired: function(aURI, aVisitTime, aWholeEntry) {},
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Ci.nsINavHistoryObserver) ||
|
||||
iid.equals(Ci.nsISupports)) {
|
||||
return this;
|
||||
}
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
};
|
||||
|
||||
var historyService = Cc["@mozilla.org/browser/nav-history-service;1"]
|
||||
.getService(Ci.nsINavHistoryService);
|
||||
historyService.addObserver(historyObserver, false);
|
||||
|
||||
/* Queries nsINavHistoryService and returns a single history entry
|
||||
* for a given URI */
|
||||
function getNavHistoryEntry(aURI) {
|
||||
var options = historyService.getNewQueryOptions();
|
||||
options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY;
|
||||
options.maxResults = 1;
|
||||
|
||||
var query = historyService.getNewQuery();
|
||||
query.uri = aURI;
|
||||
|
||||
var result = historyService.executeQuery(query, options);
|
||||
result.root.containerOpen = true;
|
||||
|
||||
if (!result.root.childCount) {
|
||||
return null;
|
||||
}
|
||||
return result.root.getChild(0);
|
||||
}
|
||||
|
||||
|
||||
function onPageLoad() {
|
||||
gBrowser.selectedBrowser.removeEventListener(
|
||||
"DOMContentLoaded", onPageLoad, true);
|
||||
|
||||
// Now that the page is loaded, click on fragment link
|
||||
EventUtils.sendMouseEvent({type:'click'}, 'firefox-link',
|
||||
gBrowser.selectedBrowser.contentWindow);
|
||||
|
||||
// Give the event system enough time to do its things
|
||||
setTimeout(function() {
|
||||
gBrowser.removeCurrentTab();
|
||||
}, 100);
|
||||
|
||||
// Test finishes in historyObserver.onTitleChanged() above
|
||||
}
|
||||
|
||||
// Make sure neither of the test pages haven't been loaded before.
|
||||
var info = getNavHistoryEntry(makeURI(pageurl));
|
||||
ok(!info, "The test page must not have been visited already.");
|
||||
info = getNavHistoryEntry(makeURI(fragmenturl));
|
||||
ok(!info, "The fragment test page must not have been visited already.");
|
||||
|
||||
// Now open the test page in a new tab
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener(
|
||||
"DOMContentLoaded", onPageLoad, true);
|
||||
content.location = pageurl;
|
||||
}
|
35
docshell/test/browser/file_bug503832.html
Normal file
35
docshell/test/browser/file_bug503832.html
Normal file
@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<!--
|
||||
Test page for https://bugzilla.mozilla.org/show_bug.cgi?id=503832
|
||||
-->
|
||||
<head>
|
||||
<title>Page Title for Bug 503832</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Fragment links</h1>
|
||||
|
||||
<p>This page has a bunch of fragment links to sections below:</p>
|
||||
|
||||
<ul>
|
||||
<li><a id="firefox-link" href="#firefox">Firefox</a></li>
|
||||
<li><a id="thunderbird-link" href="#thunderbird">Thunderbird</a></li>
|
||||
<li><a id="seamonkey-link" href="#seamonkey">Seamonkey</a></li>
|
||||
</ul>
|
||||
|
||||
<p>And here are the sections:</p>
|
||||
|
||||
<h2 id="firefox">Firefox</h2>
|
||||
|
||||
<p>Firefox is a browser.</p>
|
||||
|
||||
<h2 id="thunderbird">Thunderbird</h2>
|
||||
|
||||
<p>Thunderbird is an email client</p>
|
||||
|
||||
<h2 id="seamonkey">Seamonkey</h2>
|
||||
|
||||
<p>Seamonkey is the all-in-one application.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user