зеркало из https://github.com/mozilla/pjs.git
Fixing bug 372098. HTML links with target="" should use the base target. r=Olli.Pettay@gmail.com, sr=jonas@sicking.cc
This commit is contained in:
Родитель
0291ed98e3
Коммит
b1cb10192a
|
@ -290,7 +290,10 @@ nsHTMLAnchorElement::IsLink(nsIURI** aURI) const
|
|||
void
|
||||
nsHTMLAnchorElement::GetLinkTarget(nsAString& aTarget)
|
||||
{
|
||||
GetTarget(aTarget);
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::target, aTarget);
|
||||
if (aTarget.IsEmpty()) {
|
||||
GetBaseTarget(aTarget);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -185,7 +185,10 @@ nsHTMLAreaElement::IsLink(nsIURI** aURI) const
|
|||
void
|
||||
nsHTMLAreaElement::GetLinkTarget(nsAString& aTarget)
|
||||
{
|
||||
GetTarget(aTarget);
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::target, aTarget);
|
||||
if (aTarget.IsEmpty()) {
|
||||
GetBaseTarget(aTarget);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -340,7 +340,8 @@ nsHTMLLinkElement::IsLink(nsIURI** aURI) const
|
|||
void
|
||||
nsHTMLLinkElement::GetLinkTarget(nsAString& aTarget)
|
||||
{
|
||||
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::target, aTarget)) {
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::target, aTarget);
|
||||
if (aTarget.IsEmpty()) {
|
||||
GetBaseTarget(aTarget);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,6 +70,8 @@ _TEST_FILES = test_bug589.html \
|
|||
test_bug340800.html \
|
||||
test_bug330705-1.html \
|
||||
test_bug373589.html \
|
||||
bug372098-link-target.html \
|
||||
test_bug372098.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<html>
|
||||
<script type="text/javascript">
|
||||
|
||||
parent.callback(location.search.substr(1));
|
||||
|
||||
</script>
|
||||
</html>
|
|
@ -0,0 +1,74 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=372098
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 372098</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<base target="bug372098"></base>
|
||||
</head>
|
||||
<body onload="handle_load();">
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=372098">Mozilla Bug 372098</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display:none;">
|
||||
<iframe name="bug372098"></iframe>
|
||||
<a id="a" href="bug372098-link-target.html?a" target="">link</a>
|
||||
<link id="link" href="bug372098-link-target.html?link" target=""/>
|
||||
<map>
|
||||
<area id="area" shape="default" href="bug372098-link-target.html?area" target=""/>
|
||||
</map>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var a_passed = false;
|
||||
var link_passed = false;
|
||||
var area_passed = false;
|
||||
|
||||
/* Start the test */
|
||||
|
||||
function handle_load()
|
||||
{
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
sendMouseEvent({type:'click'}, 'a');
|
||||
}
|
||||
|
||||
/* Finish the test */
|
||||
|
||||
function finish_test()
|
||||
{
|
||||
ok(a_passed, "The 'a' element used the correct target.");
|
||||
ok(link_passed, "The 'link' element used the correct target.");
|
||||
ok(area_passed, "The 'area' element used the correct target.");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
/* Callback function used by the linked document */
|
||||
|
||||
function callback(tag)
|
||||
{
|
||||
switch (tag) {
|
||||
case 'a':
|
||||
a_passed = true;
|
||||
sendMouseEvent({type:'click'}, 'link');
|
||||
return;
|
||||
case 'link':
|
||||
link_passed = true;
|
||||
sendMouseEvent({type:'click'}, 'area');
|
||||
return;
|
||||
case 'area':
|
||||
area_passed = true;
|
||||
finish_test();
|
||||
return;
|
||||
}
|
||||
throw new Error("Eh??? We only test the 'a', 'link' and 'area' elements.");
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,11 +1,56 @@
|
|||
/**
|
||||
* EventUtils provides some utility methods for creating and sending DOM events.
|
||||
* Current methods:
|
||||
* sendMouseEvent
|
||||
* sendChar
|
||||
* sendString
|
||||
* sendKey
|
||||
*/
|
||||
|
||||
/**
|
||||
* Send a mouse event to the node with id aTarget. The "event" passed in to
|
||||
* aEvent is just a JavaScript object with the properties set that the real
|
||||
* mouse event object should have. This includes the type of the mouse event.
|
||||
* E.g. to send an click event to the node with id 'node' you might do this:
|
||||
*
|
||||
* sendMouseEvent({type:'click'}, 'node');
|
||||
*/
|
||||
function sendMouseEvent(aEvent, aTarget) {
|
||||
if (['click', 'mousedown', 'mouseup', 'mouseover', 'mouseout'].indexOf(aEvent.type) == -1) {
|
||||
throw new Error("sendMouseEvent doesn't know about event type '"+aEvent.type+"'");
|
||||
}
|
||||
|
||||
// For events to trigger the UA's default actions they need to be "trusted"
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
|
||||
|
||||
var event = document.createEvent('MouseEvent');
|
||||
|
||||
var typeArg = aEvent.type;
|
||||
var canBubbleArg = true;
|
||||
var cancelableArg = true;
|
||||
var viewArg = window;
|
||||
var detailArg = aEvent.detail || (aEvent.type == 'click' ||
|
||||
aEvent.type == 'mousedown' ||
|
||||
aEvent.type == 'mouseup' ? 1 : 0);
|
||||
var screenXArg = aEvent.screenX || 0;
|
||||
var screenYArg = aEvent.screenY || 0;
|
||||
var clientXArg = aEvent.clientX || 0;
|
||||
var clientYArg = aEvent.clientY || 0;
|
||||
var ctrlKeyArg = aEvent.ctrlKey || false;
|
||||
var altKeyArg = aEvent.altKey || false;
|
||||
var shiftKeyArg = aEvent.shiftKey || false;
|
||||
var metaKeyArg = aEvent.metaKey || false;
|
||||
var buttonArg = aEvent.button || 0;
|
||||
var relatedTargetArg = aEvent.relatedTarget || null;
|
||||
|
||||
event.initMouseEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg,
|
||||
screenXArg, screenYArg, clientXArg, clientYArg,
|
||||
ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg,
|
||||
buttonArg, relatedTargetArg);
|
||||
|
||||
document.getElementById(aTarget).dispatchEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the char aChar to the node with id aTarget. If aTarget is not
|
||||
* provided, use "target". This method handles casing of chars (sends the
|
||||
|
|
Загрузка…
Ссылка в новой задаче