Fix a few scriptable helpers to correctly communicate
NS_SUCCESS_I_DID_SOMETHING. Bug 396843, r+sr+a=jst git-svn-id: svn://10.0.0.236/trunk@236839 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
b2edd50250
commit
722f54dab5
@ -8154,35 +8154,27 @@ nsHTMLDocumentSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *obj, jsval id,
|
||||
jsval *vp, PRBool *_retval)
|
||||
{
|
||||
// nsDocumentSH::GetProperty() does a security check for us, call
|
||||
// that first...
|
||||
nsresult rv = nsDocumentSH::GetProperty(wrapper, cx, obj, id, vp, _retval);
|
||||
if (!*_retval) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// For native wrappers, do not get random names on document
|
||||
if (ObjectIsNativeWrapper(cx, obj)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> result;
|
||||
if (!ObjectIsNativeWrapper(cx, obj)) {
|
||||
nsCOMPtr<nsISupports> result;
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
rv = ResolveImpl(cx, wrapper, id, getter_AddRefs(result));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsresult rv = ResolveImpl(cx, wrapper, id, getter_AddRefs(result));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (result) {
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
rv = WrapNative(cx, obj, result, NS_GET_IID(nsISupports), vp,
|
||||
getter_AddRefs(holder));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = NS_SUCCESS_I_DID_SOMETHING;
|
||||
if (result) {
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
rv = WrapNative(cx, obj, result, NS_GET_IID(nsISupports), vp,
|
||||
getter_AddRefs(holder));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = NS_SUCCESS_I_DID_SOMETHING;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
return nsDocumentSH::GetProperty(wrapper, cx, obj, id, vp, _retval);
|
||||
}
|
||||
|
||||
// HTMLElement helper
|
||||
@ -8322,25 +8314,23 @@ nsHTMLFormElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
|
||||
return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
PRInt32 n = GetArrayIndexFromId(cx, id);
|
||||
|
||||
return NS_OK; // Don't fall through
|
||||
}
|
||||
if (n >= 0) {
|
||||
nsCOMPtr<nsIFormControl> control;
|
||||
form->GetElementAt(n, getter_AddRefs(control));
|
||||
|
||||
PRInt32 n = GetArrayIndexFromId(cx, id);
|
||||
|
||||
if (n >= 0) {
|
||||
nsCOMPtr<nsIFormControl> control;
|
||||
form->GetElementAt(n, getter_AddRefs(control));
|
||||
|
||||
if (control) {
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
nsresult rv = WrapNative(cx, obj, control, NS_GET_IID(nsISupports), vp,
|
||||
getter_AddRefs(holder));
|
||||
return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
|
||||
if (control) {
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
nsresult rv = WrapNative(cx, obj, control, NS_GET_IID(nsISupports), vp,
|
||||
getter_AddRefs(holder));
|
||||
return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return nsHTMLElementSH::GetProperty(wrapper, cx, obj, id, vp, _retval);;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -8449,10 +8439,11 @@ nsHTMLSelectElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = NS_SUCCESS_I_DID_SOMETHING;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
return nsHTMLElementSH::GetProperty(wrapper, cx, obj, id, vp, _retval);;
|
||||
}
|
||||
|
||||
// static
|
||||
@ -8734,7 +8725,7 @@ nsHTMLPluginObjElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
|
||||
return *_retval ? NS_SUCCESS_I_DID_SOMETHING : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return nsHTMLElementSH::GetProperty(wrapper, cx, obj, id, vp, _retval);;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
||||
@ -57,6 +57,7 @@ _TEST_FILES = \
|
||||
test_bug377539.html \
|
||||
test_bug384122.html \
|
||||
test_bug393974.html \
|
||||
test_bug396843.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
|
||||
302
mozilla/dom/tests/mochitest/bugs/test_bug396843.html
Normal file
302
mozilla/dom/tests/mochitest/bugs/test_bug396843.html
Normal file
@ -0,0 +1,302 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=396843
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 396843</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=396843">Mozilla Bug 396843</a>
|
||||
<p id="display">
|
||||
<iframe src="http://example.org:80/" id="t"></iframe>
|
||||
</p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 396843 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var allNodes = [];
|
||||
var XMLNodes = [];
|
||||
var failNodes = [];
|
||||
|
||||
// HTML
|
||||
function HTML_TAG(name) {
|
||||
allNodes.push(document.createElement(name));
|
||||
}
|
||||
|
||||
/* List copy/pasted from nsHTMLTagList.h */
|
||||
HTML_TAG("a", "Anchor")
|
||||
HTML_TAG("abbr", "Span")
|
||||
HTML_TAG("acronym", "Span")
|
||||
HTML_TAG("address", "Span")
|
||||
HTML_TAG("applet", "SharedObject")
|
||||
HTML_TAG("area", "Area")
|
||||
HTML_TAG("b", "Span")
|
||||
HTML_TAG("base", "Shared")
|
||||
HTML_TAG("basefont", "Shared")
|
||||
HTML_TAG("bdo", "Span")
|
||||
HTML_TAG("bgsound", "Span")
|
||||
HTML_TAG("big", "Span")
|
||||
HTML_TAG("blink", "Span")
|
||||
HTML_TAG("blockquote", "Shared")
|
||||
HTML_TAG("body", "Body")
|
||||
HTML_TAG("br", "BR")
|
||||
HTML_TAG("button", "Button")
|
||||
HTML_TAG("canvas", "Canvas")
|
||||
HTML_TAG("caption", "TableCaption")
|
||||
HTML_TAG("center", "Span")
|
||||
HTML_TAG("cite", "Span")
|
||||
HTML_TAG("code", "Span")
|
||||
HTML_TAG("col", "TableCol")
|
||||
HTML_TAG("colgroup", "TableCol")
|
||||
HTML_TAG("dd", "Span")
|
||||
HTML_TAG("del", "Mod")
|
||||
HTML_TAG("dfn", "Span")
|
||||
HTML_TAG("dir", "Shared")
|
||||
HTML_TAG("div", "Div")
|
||||
HTML_TAG("dl", "SharedList")
|
||||
HTML_TAG("dt", "Span")
|
||||
HTML_TAG("em", "Span")
|
||||
HTML_TAG("embed", "SharedObject")
|
||||
HTML_TAG("fieldset", "FieldSet")
|
||||
HTML_TAG("font", "Font")
|
||||
HTML_TAG("form", "Form")
|
||||
HTML_TAG("frame", "Frame")
|
||||
HTML_TAG("frameset", "FrameSet")
|
||||
HTML_TAG("h1", "Heading")
|
||||
HTML_TAG("h2", "Heading")
|
||||
HTML_TAG("h3", "Heading")
|
||||
HTML_TAG("h4", "Heading")
|
||||
HTML_TAG("h5", "Heading")
|
||||
HTML_TAG("h6", "Heading")
|
||||
HTML_TAG("head", "Head")
|
||||
HTML_TAG("hr", "HR")
|
||||
HTML_TAG("html", "Html")
|
||||
HTML_TAG("i", "Span")
|
||||
HTML_TAG("iframe", "IFrame")
|
||||
HTML_TAG("image", "Span")
|
||||
HTML_TAG("img", "Image")
|
||||
HTML_TAG("input", "Input")
|
||||
HTML_TAG("ins", "Mod")
|
||||
HTML_TAG("isindex", "Shared")
|
||||
HTML_TAG("kbd", "Span")
|
||||
HTML_TAG("keygen", "Span")
|
||||
HTML_TAG("label", "Label")
|
||||
HTML_TAG("legend", "Legend")
|
||||
HTML_TAG("li", "LI")
|
||||
HTML_TAG("link", "Link")
|
||||
HTML_TAG("listing", "Span")
|
||||
HTML_TAG("map", "Map")
|
||||
HTML_TAG("marquee", "Div")
|
||||
HTML_TAG("menu", "Shared")
|
||||
HTML_TAG("meta", "Meta")
|
||||
HTML_TAG("multicol", "Span")
|
||||
HTML_TAG("nobr", "Span")
|
||||
HTML_TAG("noembed", "Div")
|
||||
HTML_TAG("noframes", "Div")
|
||||
HTML_TAG("noscript", "Div")
|
||||
HTML_TAG("object", "Object")
|
||||
HTML_TAG("ol", "SharedList")
|
||||
HTML_TAG("optgroup", "OptGroup")
|
||||
HTML_TAG("option", "Option")
|
||||
HTML_TAG("p", "Paragraph")
|
||||
HTML_TAG("param", "Shared")
|
||||
HTML_TAG("plaintext", "Span")
|
||||
HTML_TAG("pre", "Pre")
|
||||
HTML_TAG("q", "Shared")
|
||||
HTML_TAG("s", "Span")
|
||||
HTML_TAG("samp", "Span")
|
||||
HTML_TAG("script", "Script")
|
||||
HTML_TAG("select", "Select")
|
||||
HTML_TAG("small", "Span")
|
||||
HTML_TAG("spacer", "Shared")
|
||||
HTML_TAG("span", "Span")
|
||||
HTML_TAG("strike", "Span")
|
||||
HTML_TAG("strong", "Span")
|
||||
HTML_TAG("style", "Style")
|
||||
HTML_TAG("sub", "Span")
|
||||
HTML_TAG("sup", "Span")
|
||||
HTML_TAG("table", "Table")
|
||||
HTML_TAG("tbody", "TableSection")
|
||||
HTML_TAG("td", "TableCell")
|
||||
HTML_TAG("textarea", "TextArea")
|
||||
HTML_TAG("tfoot", "TableSection")
|
||||
HTML_TAG("th", "TableCell")
|
||||
HTML_TAG("thead", "TableSection")
|
||||
HTML_TAG("title", "Title")
|
||||
HTML_TAG("tr", "TableRow")
|
||||
HTML_TAG("tt", "Span")
|
||||
HTML_TAG("u", "Span")
|
||||
HTML_TAG("ul", "SharedList")
|
||||
HTML_TAG("var", "Span")
|
||||
HTML_TAG("wbr", "Shared")
|
||||
HTML_TAG("xmp", "Span")
|
||||
|
||||
function SVG_TAG(name) {
|
||||
allNodes.push(document.createElementNS("http://www.w3.org/2000/svg", "svg"));
|
||||
}
|
||||
|
||||
// List sorta stolen from SVG element factory.
|
||||
SVG_TAG("a")
|
||||
SVG_TAG("polyline")
|
||||
SVG_TAG("polygon")
|
||||
SVG_TAG("circle")
|
||||
SVG_TAG("ellipse")
|
||||
SVG_TAG("line")
|
||||
SVG_TAG("rect")
|
||||
SVG_TAG("svg")
|
||||
SVG_TAG("g")
|
||||
SVG_TAG("foreignObject")
|
||||
SVG_TAG("path")
|
||||
SVG_TAG("text")
|
||||
SVG_TAG("tspan")
|
||||
SVG_TAG("image")
|
||||
SVG_TAG("style")
|
||||
SVG_TAG("linearGradient")
|
||||
SVG_TAG("metadata")
|
||||
SVG_TAG("radialGradient")
|
||||
SVG_TAG("stop")
|
||||
SVG_TAG("defs")
|
||||
SVG_TAG("desc")
|
||||
SVG_TAG("script")
|
||||
SVG_TAG("use")
|
||||
SVG_TAG("symbol")
|
||||
SVG_TAG("marker")
|
||||
SVG_TAG("title")
|
||||
SVG_TAG("clipPath")
|
||||
SVG_TAG("textPath")
|
||||
SVG_TAG("filter")
|
||||
SVG_TAG("feBlend")
|
||||
SVG_TAG("feColorMatrix")
|
||||
SVG_TAG("feComponentTransfer")
|
||||
SVG_TAG("feComposite")
|
||||
SVG_TAG("feFuncR")
|
||||
SVG_TAG("feFuncG")
|
||||
SVG_TAG("feFuncB")
|
||||
SVG_TAG("feFuncA")
|
||||
SVG_TAG("feGaussianBlur")
|
||||
SVG_TAG("feMerge")
|
||||
SVG_TAG("feMergeNode")
|
||||
SVG_TAG("feMorphology")
|
||||
SVG_TAG("feOffset")
|
||||
SVG_TAG("feFlood")
|
||||
SVG_TAG("feTile")
|
||||
SVG_TAG("feTurbulence")
|
||||
SVG_TAG("feConvolveMatrix")
|
||||
SVG_TAG("feDistantLight")
|
||||
SVG_TAG("fePointLight")
|
||||
SVG_TAG("feSpotLight")
|
||||
SVG_TAG("feDiffuseLighting")
|
||||
SVG_TAG("feSpecularLighting")
|
||||
SVG_TAG("feDisplacementMap")
|
||||
SVG_TAG("feImage")
|
||||
SVG_TAG("pattern")
|
||||
SVG_TAG("mask")
|
||||
SVG_TAG("svgSwitch")
|
||||
|
||||
// Toss in some other namespaced stuff too, for good measure
|
||||
allNodes.push(document.createElementNS(
|
||||
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
|
||||
"window"));
|
||||
allNodes.push(document.createElementNS("http://www.w3.org/1998/Math/MathML",
|
||||
"math"));
|
||||
allNodes.push(document.createElementNS("http://www.w3.org/2001/xml-events",
|
||||
"testname"));
|
||||
allNodes.push(document.createElementNS("bogus.namespace", "testname"));
|
||||
|
||||
var XMLDoc = document.implementation.createDocument("", "", null);
|
||||
|
||||
// And non-elements
|
||||
allNodes.push(document.createTextNode("some text"));
|
||||
allNodes.push(document.createComment("some text"));
|
||||
XMLNodes.push(XMLDoc.createCDATASection("some text"));
|
||||
failNodes.push(document.createDocumentFragment());
|
||||
XMLNodes.push(XMLDoc.createProcessingInstruction("PI", "data"));
|
||||
|
||||
function runTest() {
|
||||
ok(document.nodePrincipal === undefined, "Must not have document principal");
|
||||
ok(document.baseURIObject === undefined, "Must not have document base URI");
|
||||
ok(document.documentURIObject === undefined, "Must have document URI");
|
||||
|
||||
for (var i = 0; i < allNodes.length; ++i) {
|
||||
ok(allNodes[i].nodePrincipal === undefined,
|
||||
"Unexpected principal appears for " + allNodes[i].nodeName);
|
||||
ok(allNodes[i].baseURIObject === undefined,
|
||||
"Unexpected base URI appears for " + allNodes[i].nodeName);
|
||||
}
|
||||
}
|
||||
|
||||
function runTest2() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
isnot(document.nodePrincipal, null, "Must have document principal");
|
||||
is(document.nodePrincipal instanceof Components.interfaces.nsIPrincipal,
|
||||
true, "document principal must be a principal");
|
||||
isnot(document.baseURIObject, null, "Must have document base URI");
|
||||
is(document.baseURIObject instanceof Components.interfaces.nsIURI,
|
||||
true, "document base URI must be a URI");
|
||||
isnot(document.documentURIObject, null, "Must have document URI");
|
||||
is(document.documentURIObject instanceof Components.interfaces.nsIURI,
|
||||
true, "document URI must be a URI");
|
||||
is(document.documentURIObject.spec, document.documentURI,
|
||||
"document URI must be the right URI");
|
||||
|
||||
for (var i = 0; i < allNodes.length; ++i) {
|
||||
is(allNodes[i].nodePrincipal, document.nodePrincipal,
|
||||
"Unexpected principal for " + allNodes[i].nodeName);
|
||||
is(allNodes[i].baseURIObject, document.baseURIObject,
|
||||
"Unexpected base URI for " + allNodes[i].nodeName);
|
||||
}
|
||||
|
||||
for (i = 0; i < XMLNodes.length; ++i) {
|
||||
is(XMLNodes[i].nodePrincipal, document.nodePrincipal,
|
||||
"Unexpected principal for " + XMLNodes[i].nodeName);
|
||||
is(XMLNodes[i].baseURIObject.spec, "about:blank",
|
||||
"Unexpected base URI for " + XMLNodes[i].nodeName);
|
||||
}
|
||||
|
||||
for (i = 0; i < failNodes.length; ++i) {
|
||||
todo(failNodes[i].nodePrincipal == document.nodePrincipal,
|
||||
"Unexpected principal for " + failNodes[i].nodeName);
|
||||
todo(failNodes[i].baseURIObject == document.baseURIObject,
|
||||
"Unexpected base URI for " + failNodes[i].nodeName);
|
||||
}
|
||||
|
||||
var doc = $("t").contentDocument;
|
||||
try {
|
||||
is(doc instanceof $("t").contentWindow.HTMLDocument, true,
|
||||
"Expected an HTMLDocument here");
|
||||
todo(1, "Someone fixed bug 396849; need to update this code");
|
||||
} catch (e) {
|
||||
todo(0, "Running into bug 396849");
|
||||
}
|
||||
isnot(doc.nodePrincipal, null, "Must have doc principal");
|
||||
is(doc.nodePrincipal instanceof Components.interfaces.nsIPrincipal,
|
||||
true, "doc principal must be a principal");
|
||||
isnot(doc.baseURIObject, null, "Must have doc base URI");
|
||||
is(doc.baseURIObject instanceof Components.interfaces.nsIURI,
|
||||
true, "doc base URI must be a URI");
|
||||
isnot(doc.documentURIObject, null, "Must have doc URI");
|
||||
is(doc.documentURIObject instanceof Components.interfaces.nsIURI,
|
||||
true, "doc URI must be a URI");
|
||||
is(doc.documentURIObject.spec, doc.documentURI,
|
||||
"doc URI must be the right URI");
|
||||
}
|
||||
|
||||
addLoadEvent(runTest);
|
||||
addLoadEvent(runTest2);
|
||||
addLoadEvent(runTest);
|
||||
addLoadEvent(SimpleTest.finish);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user