Commit 8cef0752 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Convert fast/dom/element-attribute-js-null.html to utilize w3c test harness

This patch changes "element-attribute-js-null.html" to utilize w3c test
harnes for ease of maintenance and avoid timeout for dumping result.

This patch is a preparation of the patch[1].

[1] http://crrev.com/c/1337224 Utilize NGInlineNode::GetOffsetMapping() in
Element#innerText

Change-Id: I4c29ac2de838556b617dddd667a55328bbb6db61
Reviewed-on: https://chromium-review.googlesource.com/c/1345688
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarYoichi Osato <yoichio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610765}
parent 9b79c9a2
This test setting various attributes of a elements to JavaScript null.
TEST SUCCEEDED: The value was null. [tested Node.nodeValue]
TEST SUCCEEDED: The value was the empty string. [tested Node.textContent]
TEST SUCCEEDED: The value was the string 'null'. [tested Element.id]
TEST SUCCEEDED: The value was the string 'null'. [tested Element.className]
TEST SUCCEEDED: The value was the empty string. [tested Element.innerHTML]
TEST SUCCEEDED: Exception (NoModificationAllowedError: Failed to set the 'outerHTML' property on 'Element': This element has no parent node.) was thrown as expected. [tested Element.outerHTML]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLElement.accessKey]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLElement.title]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLElement.lang]
TEST SUCCEEDED: The value was the empty string. [tested HTMLElement.dir]
TEST SUCCEEDED: The value was the empty string. [tested HTMLElement.innerText]
TEST SUCCEEDED: Exception (NoModificationAllowedError: Failed to set the 'outerText' property on 'HTMLElement': The element has no parent.) was thrown as expected. [tested HTMLElement.outerText]
TEST SUCCEEDED: Exception (SyntaxError: Failed to set the 'contentEditable' property on 'HTMLElement': The value provided ('null') is not one of 'true', 'false', 'plaintext-only', or 'inherit'.) was thrown as expected. [tested HTMLElement.contentEditable]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLAnchorElement.charset]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLAnchorElement.coords]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLAnchorElement.download]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLAnchorElement.href]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLAnchorElement.hreflang]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLAnchorElement.name]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLAnchorElement.ping]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLAnchorElement.rel]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLAnchorElement.rev]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLAnchorElement.shape]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLAnchorElement.target]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLAnchorElement.type]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLAreaElement.alt]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLAreaElement.coords]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLAreaElement.href]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLAreaElement.ping]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLAreaElement.shape]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLAreaElement.target]
TEST SUCCEEDED: The value was the string 'metadata'. [tested HTMLAudioElement.preload]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLAudioElement.src]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLBaseElement.href]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLBaseElement.target]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLBlockquoteElement.cite]
TEST SUCCEEDED: The value was the empty string. [tested HTMLBodyElement.aLink]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLBodyElement.background]
TEST SUCCEEDED: The value was the empty string. [tested HTMLBodyElement.bgColor]
TEST SUCCEEDED: The value was the empty string. [tested HTMLBodyElement.link]
TEST SUCCEEDED: The value was the empty string. [tested HTMLBodyElement.text]
TEST SUCCEEDED: The value was the empty string. [tested HTMLBodyElement.vLink]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLBRElement.clear]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLButtonElement.formAction]
TEST SUCCEEDED: The value was the string 'application/x-www-form-urlencoded'. [tested HTMLButtonElement.formEnctype]
TEST SUCCEEDED: The value was the string 'get'. [tested HTMLButtonElement.formMethod]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLButtonElement.formTarget]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLButtonElement.name]
TEST SUCCEEDED: The value was the string 'submit'. [tested HTMLButtonElement.type]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLButtonElement.value]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLDivElement.align]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLEmbedElement.align]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLEmbedElement.height]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLEmbedElement.name]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLEmbedElement.src]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLEmbedElement.type]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLEmbedElement.width]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLFieldSetElement.name]
TEST SUCCEEDED: The value was the empty string. [tested HTMLFontElement.color]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLFontElement.face]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLFontElement.size]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLFormElement.acceptCharset]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLFormElement.action]
TEST SUCCEEDED: The value was the string 'on'. [tested HTMLFormElement.autocomplete]
TEST SUCCEEDED: The value was the string 'application/x-www-form-urlencoded'. [tested HTMLFormElement.enctype]
TEST SUCCEEDED: The value was the string 'application/x-www-form-urlencoded'. [tested HTMLFormElement.encoding]
TEST SUCCEEDED: The value was the string 'get'. [tested HTMLFormElement.method]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLFormElement.name]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLFormElement.target]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLFrameElement.frameBorder]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLFrameElement.longDesc]
TEST SUCCEEDED: The value was the empty string. [tested HTMLFrameElement.marginHeight]
TEST SUCCEEDED: The value was the empty string. [tested HTMLFrameElement.marginWidth]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLFrameElement.name]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLFrameElement.scrolling]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLFrameElement.src]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLFrameSetElement.cols]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLFrameSetElement.rows]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLHeadingElement.align]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLHRElement.align]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLHRElement.color]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLHRElement.size]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLHRElement.width]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLHtmlElement.version]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLIFrameElement.align]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLIFrameElement.frameBorder]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLIFrameElement.height]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLIFrameElement.longDesc]
TEST SUCCEEDED: The value was the empty string. [tested HTMLIFrameElement.marginHeight]
TEST SUCCEEDED: The value was the empty string. [tested HTMLIFrameElement.marginWidth]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLIFrameElement.name]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLIFrameElement.scrolling]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLIFrameElement.src]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLIFrameElement.srcdoc]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLIFrameElement.width]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLImageElement.align]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLImageElement.alt]
TEST SUCCEEDED: The value was the empty string. [tested HTMLImageElement.border]
TEST SUCCEEDED: The value was null. [tested HTMLImageElement.crossOrigin]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLImageElement.longDesc]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLImageElement.lowsrc]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLImageElement.name]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLImageElement.src]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLImageElement.srcset]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLImageElement.useMap]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLInputElement.accept]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLInputElement.align]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLInputElement.alt]
TEST SUCCEEDED: The value was the empty string. [tested HTMLInputElement.autocomplete]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLInputElement.defaultValue]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLInputElement.dirName]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLInputElement.formAction]
TEST SUCCEEDED: The value was the string 'application/x-www-form-urlencoded'. [tested HTMLInputElement.formEnctype]
TEST SUCCEEDED: The value was the string 'get'. [tested HTMLInputElement.formMethod]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLInputElement.formTarget]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLInputElement.max]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLInputElement.min]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLInputElement.name]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLInputElement.pattern]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLInputElement.placeholder]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLInputElement.src]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLInputElement.step]
TEST SUCCEEDED: The value was the string 'text'. [tested HTMLInputElement.type]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLInputElement.useMap]
TEST SUCCEEDED: The value was the empty string. [tested HTMLInputElement.value]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLLabelElement.htmlFor]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLLegendElement.align]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLLIElement.type]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLLinkElement.charset]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLLinkElement.href]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLLinkElement.hreflang]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLLinkElement.media]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLLinkElement.rel]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLLinkElement.rev]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLLinkElement.target]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLLinkElement.type]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLMapElement.name]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLMarqueeElement.behavior]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLMarqueeElement.bgColor]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLMarqueeElement.direction]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLMarqueeElement.height]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLMarqueeElement.width]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLMetaElement.content]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLMetaElement.httpEquiv]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLMetaElement.name]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLMetaElement.scheme]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLModElement.cite]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLModElement.dateTime]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLObjectElement.code]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLObjectElement.align]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLObjectElement.archive]
TEST SUCCEEDED: The value was the empty string. [tested HTMLObjectElement.border]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLObjectElement.codeBase]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLObjectElement.codeType]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLObjectElement.data]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLObjectElement.height]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLObjectElement.name]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLObjectElement.standby]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLObjectElement.type]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLObjectElement.useMap]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLObjectElement.width]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLOListElement.type]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLOptGroupElement.label]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLOptionElement.text]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLOptionElement.label]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLOptionElement.value]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLOutputElement.name]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLOutputElement.defaultValue]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLOutputElement.value]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLParagraphElement.align]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLParamElement.name]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLParamElement.type]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLParamElement.value]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLParamElement.valueType]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLQuoteElement.cite]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLScriptElement.text]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLScriptElement.htmlFor]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLScriptElement.event]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLScriptElement.charset]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLScriptElement.src]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLScriptElement.type]
TEST SUCCEEDED: The value was null. [tested HTMLScriptElement.crossOrigin]
TEST SUCCEEDED: The value was the empty string. [tested HTMLSelectElement.value]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLSelectElement.name]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLSourceElement.src]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLSourceElement.type]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLStyleElement.media]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLStyleElement.type]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableCaptionElement.align]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableCellElement.abbr]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableCellElement.align]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableCellElement.axis]
TEST SUCCEEDED: The value was the empty string. [tested HTMLTableCellElement.bgColor]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableCellElement.ch]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableCellElement.chOff]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableCellElement.headers]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableCellElement.height]
TEST SUCCEEDED: The value was the empty string. [tested HTMLTableCellElement.scope]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableCellElement.vAlign]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableCellElement.width]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableColElement.align]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableColElement.ch]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableColElement.chOff]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableColElement.vAlign]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableColElement.width]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableElement.align]
TEST SUCCEEDED: The value was the empty string. [tested HTMLTableElement.bgColor]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableElement.border]
TEST SUCCEEDED: The value was the empty string. [tested HTMLTableElement.cellPadding]
TEST SUCCEEDED: The value was the empty string. [tested HTMLTableElement.cellSpacing]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableElement.frame]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableElement.rules]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableElement.summary]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableElement.width]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableRowElement.align]
TEST SUCCEEDED: The value was the empty string. [tested HTMLTableRowElement.bgColor]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableRowElement.ch]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableRowElement.chOff]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableRowElement.vAlign]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableSectionElement.align]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableSectionElement.ch]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableSectionElement.chOff]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableSectionElement.vAlign]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTextAreaElement.defaultValue]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTextAreaElement.dirName]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTextAreaElement.name]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTextAreaElement.placeholder]
TEST SUCCEEDED: The value was the empty string. [tested HTMLTextAreaElement.value]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTextAreaElement.wrap]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTitleElement.text]
TEST SUCCEEDED: The value was the string 'metadata'. [tested HTMLTrackElement.kind]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTrackElement.label]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLTrackElement.src]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTrackElement.srclang]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLUListElement.type]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLVideoElement.poster]
TEST SUCCEEDED: The value was the string 'metadata'. [tested HTMLVideoElement.preload]
TEST SUCCEEDED: The value was the string 'null' resolved as a URL. [tested HTMLVideoElement.src]
<html>
<head>
<style type="text/css">
.pass { color: green; }
.fail { color: red; }
</style>
<!doctype HTML>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
function printOut(msg)
{
var console = document.getElementById("console");
var span = document.createElement('span');
span.innerHTML = msg + '<br>';
console.appendChild(span);
}
function resultStringifier(result)
{
if (result === "")
return "<b>the empty string</b>";
else if (result === null)
return "<b>null</b>";
else if (result === undefined)
return "<b>undefined</b>";
return "the string '" + result + "'";
}
// TODO(yosin): We should merge this test into
// "external/wpt/html/dom/reflection*.*" to avoid duplicated test cases.
// This test setting various attributes of a elements to JavaScript null
function resolve(url)
{
......@@ -31,39 +13,26 @@
return a.href;
}
function nullTestElementAttribute(elementType, element, attr, expected, isUrl)
function nullTestElementAttribute(elementType, element, attr)
{
var exceptionThrown;
try {
element[attr] = null;
} catch (ec) {
exceptionThrown = ec;
}
var result;
if (exceptionThrown) {
if (expected === 'exception')
result = "<span class='pass'>TEST SUCCEEDED:</span> Exception (" + exceptionThrown + ") was thrown as expected.";
else
result = "<span class='fail'>TEST FAILED:</span> An exception was thrown unexpectedly.";
} else {
if (expected === 'exception')
result = "<span class='fail'>TEST FAILED:</span> An exception should have been thrown.";
else if (isUrl && element[attr] === resolve(expected))
result = "<span class='pass'>TEST SUCCEEDED:</span> The value was " + resultStringifier(expected) + " resolved as a URL.";
else if (!isUrl && element[attr] === expected)
result = "<span class='pass'>TEST SUCCEEDED:</span> The value was " + resultStringifier(expected) + ".";
const expectedValue = attr.expectedNull;
test(() => {
if (attr.isException) {
assert_throws(expectedValue,
() => element[attr.name] = null);
return;
}
element[attr.name] = null;
const actualValue = element[attr.name];
if (attr.isUrl)
assert_equals(actualValue, resolve(expectedValue));
else
result = "<span class='fail'>TEST FAILED:</span> The value should have been " + resultStringifier(expected) + " but was " + resultStringifier(element[attr]) + ".";
}
result += " [tested " + elementType + "." + attr + "]";
printOut(result);
assert_equals(actualValue, expectedValue);
}, `${elementType}.${attr.name}`);
}
function runTests()
{
if (window.testRunner)
testRunner.dumpAsText();
// Others to test:
// Core DOM
// Attr.value (expected: null)
......@@ -87,7 +56,9 @@
{name: 'id', expectedNull: 'null'},
{name: 'className', expectedNull: 'null'},
{name: 'innerHTML', expectedNull: ''},
{name: 'outerHTML', expectedNull: 'exception'}
{name: 'outerHTML',
expectedNull: 'NoModificationAllowedError',
isException: true}
]
},
{
......@@ -99,8 +70,11 @@
{name: 'lang', expectedNull: 'null'},
{name: 'dir', expectedNull: ''},
{name: 'innerText', expectedNull: ''},
{name: 'outerText', expectedNull: 'exception'},
{name: 'contentEditable', expectedNull: 'exception'}
{name: 'outerText',
expectedNull: 'NoModificationAllowedError',
isException: true},
{name: 'contentEditable', expectedNull: 'SyntaxError',
isException: true}
]
},
{
......@@ -666,20 +640,10 @@
}
];
for (element in listing) {
var type = listing[element].type;
var elementToUse = listing[element].elementToUse;
var attrs = listing[element].attributes;
for (attr in attrs) {
nullTestElementAttribute(type, elementToUse, attrs[attr].name, attrs[attr].expectedNull, attrs[attr].isUrl);
}
printOut('');
for (const {type, elementToUse, attributes} of listing) {
for (const attr of attributes)
nullTestElementAttribute(type, elementToUse, attr);
}
}
runTests();
</script>
</head>
<body onload="runTests()">
<p>This test setting various attributes of a elements to JavaScript null.</p>
<div id="console"></div>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment