mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Update web-platform-tests to revision 1e4fe87a7f01c0b5c614c8f601ffa68b4a00662a
This commit is contained in:
parent
4c3f1756da
commit
432648745e
164 changed files with 8354 additions and 595 deletions
|
@ -7,47 +7,89 @@
|
|||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
function setColorAttributes(doc, color) {
|
||||
doc.fgColor = color;
|
||||
doc.bgColor = color;
|
||||
doc.linkColor = color;
|
||||
doc.vlinkColor = color;
|
||||
doc.alinkColor = color;
|
||||
}
|
||||
|
||||
function checkColorAttributes(doc, expected) {
|
||||
assert_equals(document.fgColor, expected);
|
||||
assert_equals(document.bgColor, expected);
|
||||
assert_equals(document.linkColor, expected);
|
||||
assert_equals(document.vlinkColor, expected);
|
||||
assert_equals(document.alinkColor, expected);
|
||||
}
|
||||
|
||||
test(function() {
|
||||
document.fgColor = "green";
|
||||
document.bgColor = "green";
|
||||
document.linkColor = "green";
|
||||
document.vlinkColor = "green";
|
||||
document.alinkColor = "green";
|
||||
setColorAttributes(document, 'green');
|
||||
|
||||
var body = document.documentElement.removeChild(document.body);
|
||||
|
||||
this.add_cleanup(function() {
|
||||
// Re-add body and reset color attributes.
|
||||
document.body = body;
|
||||
setColorAttributes(document, '');
|
||||
});
|
||||
// When there is no body element, the color attributes return an
|
||||
// empty string upon getting.
|
||||
assert_equals(document.fgColor, "");
|
||||
assert_equals(document.bgColor, "");
|
||||
assert_equals(document.linkColor, "");
|
||||
assert_equals(document.vlinkColor, "");
|
||||
assert_equals(document.alinkColor, "");
|
||||
|
||||
// Re-add body and reset color attributes.
|
||||
document.body = body;
|
||||
document.fgColor = "";
|
||||
document.bgColor = "";
|
||||
document.linkColor = "";
|
||||
document.vlinkColor = "";
|
||||
document.alinkColor = "";
|
||||
checkColorAttributes(document, '');
|
||||
}, "getting document color attributes with no body");
|
||||
|
||||
test(function() {
|
||||
var body = document.documentElement.removeChild(document.body);
|
||||
this.add_cleanup(function() {
|
||||
document.body = body;
|
||||
});
|
||||
|
||||
// When there is no body element, setting the color attributes has no effect.
|
||||
document.fgColor = "red";
|
||||
document.bgColor = "red";
|
||||
document.linkColor = "red";
|
||||
document.vlinkColor = "red";
|
||||
document.alinkColor = "red";
|
||||
assert_equals(document.fgColor, "");
|
||||
assert_equals(document.bgColor, "");
|
||||
assert_equals(document.linkColor, "");
|
||||
assert_equals(document.vlinkColor, "");
|
||||
assert_equals(document.alinkColor, "");
|
||||
|
||||
document.body = body;
|
||||
setColorAttributes(document, 'red');
|
||||
checkColorAttributes(document, '');
|
||||
}, "setting document color attributes with no body");
|
||||
|
||||
function testBogusRootElement(doc) {
|
||||
doc.replaceChild(doc.createElement('test'), doc.documentElement);
|
||||
var new_body = doc.createElement('body');
|
||||
doc.documentElement.appendChild(new_body);
|
||||
|
||||
setColorAttributes(doc, 'red');
|
||||
|
||||
assert_equals(new_body.attributes.length, 0, 'new_body.attributes.length');
|
||||
checkColorAttributes(doc, '');
|
||||
}
|
||||
|
||||
function createIframeDoc(markup) {
|
||||
var iframe = document.createElement('iframe');
|
||||
document.body.appendChild(iframe);
|
||||
var doc = iframe.contentDocument;
|
||||
doc.open();
|
||||
doc.write(markup);
|
||||
doc.close();
|
||||
return doc;
|
||||
}
|
||||
|
||||
test(function() {
|
||||
// Use standards mode for doc
|
||||
var doc = createIframeDoc('<!doctype html>');
|
||||
testBogusRootElement(doc);
|
||||
}, "document color attributes when the root element is a test element (iframe)");
|
||||
|
||||
test(function() {
|
||||
var doc = document.implementation.createHTMLDocument();
|
||||
testBogusRootElement(doc);
|
||||
}, "document color attributes when the root element is a test element (createHTMLDocument)");
|
||||
|
||||
test(function() {
|
||||
var doc = createIframeDoc('<!doctype html><frameset text=red link=red vlink=red alink=red bgcolor=red>');
|
||||
assert_equals(doc.body.attributes.length, 5, 'attributes.length on the frameset');
|
||||
checkColorAttributes(doc, '');
|
||||
}, "getting document color attributes when document.body is a frameset");
|
||||
|
||||
test(function() {
|
||||
var doc = createIframeDoc('<!doctype html><frameset>');
|
||||
setColorAttributes(doc, 'red');
|
||||
assert_equals(doc.body.attributes.length, 0, 'attributes.length on the frameset');
|
||||
checkColorAttributes(doc, '');
|
||||
}, "setting document color attributes when document.body is a frameset");
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue