Bug 519926. When the string is an optional argument and isn't passed, pval is null. r=jorendorff

This commit is contained in:
Zelgadis 2009-10-14 14:27:34 -04:00
parent ba826e31ee
commit c42718629c
2 changed files with 17 additions and 2 deletions

View File

@ -20,6 +20,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=478251
/** Test for Bug 478251 **/
var doc = $("t").contentDocument;
doc.open();
doc.write();
doc.close();
is(doc.documentElement.textContent, "", "Writing || failed");
doc.open();
doc.write(null);
doc.close();
@ -40,6 +45,11 @@ doc.write(undefined, undefined);
doc.close();
is(doc.documentElement.textContent, "undefinedundefined", "Writing |undefined, undefined| failed");
doc.open();
doc.writeln();
doc.close();
is(doc.documentElement.textContent, "\n", "Writing |\\n| failed");
doc.open();
doc.writeln(null);
doc.close();

View File

@ -704,10 +704,15 @@ xpc_qsDOMString::xpc_qsDOMString(JSContext *cx, jsval v, jsval *pval,
behavior = undefinedBehavior;
}
if (behavior != eStringify)
// If pval is null, that means the argument was optional and
// not passed; turn those into void strings if they're
// supposed to be stringified.
if (behavior != eStringify || !pval)
{
// Here behavior == eStringify implies !pval, so both eNull and
// eStringify should end up with void strings.
(new(mBuf) implementation_type(
traits::sEmptyBuffer, PRUint32(0)))->SetIsVoid(behavior == eNull);
traits::sEmptyBuffer, PRUint32(0)))->SetIsVoid(behavior != eEmpty);
mValid = JS_TRUE;
return;
}