mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Update web-platform-tests to revision 697b971060b2d475a73c1c3755232a4674d61cf5
This commit is contained in:
parent
f60598909a
commit
b97474fbba
236 changed files with 4817 additions and 893 deletions
|
@ -6,9 +6,9 @@
|
|||
<div id="log"></div>
|
||||
<script>
|
||||
test(function () {
|
||||
assert_throws('NotSupportedError', function() {
|
||||
document.createEvent('PopStateEvent');
|
||||
}, 'document.createEvent("PopStateEvent") should not be supported');
|
||||
var e = document.createEvent('PopStateEvent');
|
||||
var eProto = Object.getPrototypeOf(e);
|
||||
assert_equals(eProto, PopStateEvent.prototype);
|
||||
}, 'document.createEvent');
|
||||
|
||||
test(function () {
|
||||
|
|
|
@ -0,0 +1,197 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
|
||||
<title>Location objects' custom [[GetPrototypeOf]] trap permit [[Prototype]] chain cycles to be created through them</title>
|
||||
|
||||
<link rel="author" title="Jeff Walden" href="http://whereswalden.com/" />
|
||||
<link rel="help" href="https://tc39.github.io/ecma262/#sec-ordinarysetprototypeof" />
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsers.html#location-getprototypeof" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
|
||||
<hr />
|
||||
|
||||
<iframe id="same-origin-different-window"></iframe>
|
||||
<iframe id="cross-origin-joined-via-document-domain"></iframe>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
// Handle same-origin, same-window testing first, before any async-requiring
|
||||
// testing.
|
||||
test(function() {
|
||||
var LocationPrototype = Location.prototype;
|
||||
var ObjectPrototype = Object.prototype;
|
||||
|
||||
var loc = window.location;
|
||||
|
||||
var locProto = Object.getPrototypeOf(loc);
|
||||
assert_equals(locProto, LocationPrototype,
|
||||
"loc's initial [[Prototype]]");
|
||||
|
||||
var originalLocProtoProto = Object.getPrototypeOf(locProto);
|
||||
assert_equals(originalLocProtoProto, ObjectPrototype,
|
||||
"Location.prototype's initial [[Prototype]]");
|
||||
|
||||
Object.setPrototypeOf(locProto, loc);
|
||||
|
||||
assert_equals(Object.getPrototypeOf(locProto), loc,
|
||||
"LocationPrototype's new [[Prototype]]");
|
||||
assert_equals(Object.getPrototypeOf(loc), locProto,
|
||||
"loc's new [[Prototype]]");
|
||||
|
||||
// Reset so as not to muck with testharness.js expectations.
|
||||
Object.setPrototypeOf(locProto, originalLocProtoProto);
|
||||
}, "same-origin, same-window location cycle");
|
||||
|
||||
var pathdir =
|
||||
location.pathname.substring(0, location.pathname.lastIndexOf('/') + 1);
|
||||
|
||||
var triggerCrossOriginTest = (function() {
|
||||
var crossOrigin =
|
||||
document.getElementById("cross-origin-joined-via-document-domain");
|
||||
|
||||
var t = async_test("cross-origin location has null prototype");
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
crossOrigin.onload = t.step_func_done(function(e) {
|
||||
try {
|
||||
var win = crossOrigin.contentWindow;
|
||||
|
||||
var loc = win.location;
|
||||
|
||||
// Between un-opted-in windows, location objects appear to have null
|
||||
// [[Prototype]].
|
||||
assert_equals(Object.getPrototypeOf(loc), null,
|
||||
"cross-origin unjoined location's [[Prototype]");
|
||||
|
||||
resolve();
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
crossOrigin.src =
|
||||
"//{{domains[www]}}:" + location.port + pathdir + "cross_origin_joined_frame.sub.html";
|
||||
})
|
||||
.catch(t.unreached_func("crossOrigin onload/src setting"));
|
||||
})();
|
||||
|
||||
var triggerSameOriginTest = (function() {
|
||||
var sameOriginDifferentWindow =
|
||||
document.getElementById("same-origin-different-window");
|
||||
|
||||
var t = async_test("same-origin, different-window location cycle");
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
sameOriginDifferentWindow.onload = t.step_func_done(function() {
|
||||
try {
|
||||
var win = sameOriginDifferentWindow.contentWindow;
|
||||
|
||||
var loc = win.location;
|
||||
var LocationPrototype = win.Location.prototype;
|
||||
var ObjectPrototype = win.Object.prototype;
|
||||
|
||||
var locProto = Object.getPrototypeOf(loc);
|
||||
assert_equals(locProto, LocationPrototype,
|
||||
"loc's initial [[Prototype]]");
|
||||
|
||||
var originalLocProtoProto = Object.getPrototypeOf(locProto);
|
||||
assert_equals(originalLocProtoProto, ObjectPrototype,
|
||||
"Location.prototype's initial [[Prototype]]");
|
||||
|
||||
Object.setPrototypeOf(locProto, loc);
|
||||
|
||||
assert_equals(Object.getPrototypeOf(locProto), loc,
|
||||
"LocationPrototype's new [[Prototype]]");
|
||||
assert_equals(Object.getPrototypeOf(loc), locProto,
|
||||
"loc's new [[Prototype]]");
|
||||
|
||||
// Reset so as not to muck with testharness.js expectations.
|
||||
Object.setPrototypeOf(locProto, originalLocProtoProto);
|
||||
|
||||
resolve();
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
sameOriginDifferentWindow.src = "same_origin_frame.html";
|
||||
})
|
||||
.catch(t.unreached_func("sameOriginDifferentWindow onload/src setting"));
|
||||
})();
|
||||
|
||||
function crossOriginJoinTest() {
|
||||
var win =
|
||||
document.getElementById("cross-origin-joined-via-document-domain")
|
||||
.contentWindow;
|
||||
|
||||
assert_equals(document.domain, "{{host}}");
|
||||
|
||||
var loc = win.location;
|
||||
|
||||
var threw = false;
|
||||
try {
|
||||
// Still cross-origin until the document.domain set below.
|
||||
win.Location;
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
}
|
||||
|
||||
assert_equals(threw, true,
|
||||
"accessing win.Location before joining win's origin");
|
||||
|
||||
// Join with other frames that have set |document.domain| to this same
|
||||
// value -- namely, this cross-origin frame. Now access between the two
|
||||
// windows should be permitted.
|
||||
assert_equals(document.domain, "{{host}}",
|
||||
"initial document.domain sanity check");
|
||||
document.domain = "{{host}}";
|
||||
|
||||
var LocationPrototype = win.Location.prototype;
|
||||
var ObjectPrototype = win.Object.prototype;
|
||||
|
||||
var locProto = Object.getPrototypeOf(loc);
|
||||
assert_equals(locProto, LocationPrototype,
|
||||
"loc's initial [[Prototype]]");
|
||||
|
||||
var originalLocProtoProto = Object.getPrototypeOf(locProto);
|
||||
assert_equals(originalLocProtoProto, ObjectPrototype,
|
||||
"Location.prototype's initial [[Prototype]]");
|
||||
|
||||
Object.setPrototypeOf(locProto, loc);
|
||||
|
||||
assert_equals(Object.getPrototypeOf(locProto), loc,
|
||||
"LocationPrototype's new [[Prototype]]");
|
||||
assert_equals(Object.getPrototypeOf(loc), locProto,
|
||||
"loc's new [[Prototype]]");
|
||||
|
||||
// Reset so as not to muck with testharness.js expectations.
|
||||
Object.setPrototypeOf(locProto, originalLocProtoProto);
|
||||
}
|
||||
|
||||
function run() {
|
||||
var t =
|
||||
async_test("cross-origin, but joined via document.domain, location cycle");
|
||||
|
||||
// The cross-origin/joined case must be tested after both unjoined same-origin
|
||||
// and unjoined cross-origin tests: by mucking with document.domain, the
|
||||
// cross-origin/joined case makes it impossible to perform those tests.
|
||||
t.step(function() {
|
||||
Promise.all([triggerCrossOriginTest, triggerSameOriginTest])
|
||||
.then(t.step_func_done(crossOriginJoinTest),
|
||||
t.unreached_func("cross-origin joined error case"));
|
||||
});
|
||||
}
|
||||
run();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Cross-origin subframe for Location cyclic [[Prototype]] test</title>
|
||||
<link rel="author" title="Jeff Walden" href="http://whereswalden.com/" />
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
document.domain = "{{host}}";
|
||||
</script>
|
||||
<!-- this should be accessible to the parent once it sets document.domain -->
|
||||
<p>Cross-origin iframe with joined <code>document.domain</code></p>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Same-origin subframe for Location cyclic [[Prototype]] test</title>
|
||||
<link rel="author" title="Jeff Walden" href="http://whereswalden.com/" />
|
||||
</head>
|
||||
<body>
|
||||
<!-- nothing to do, this window should be accessible to the parent frame -->
|
||||
<p>Same-origin iframe</p>
|
||||
</body>
|
||||
</html>
|
|
@ -3215,7 +3215,11 @@ window.onload = function() {
|
|||
HTMLHeadingElement: ['document.createElement("h1")'],
|
||||
HTMLParagraphElement: ['document.createElement("p")'],
|
||||
HTMLHRElement: ['document.createElement("hr")'],
|
||||
HTMLPreElement: ['document.createElement("pre")'],
|
||||
HTMLPreElement: [
|
||||
'document.createElement("pre")',
|
||||
'document.createElement("listing")',
|
||||
'document.createElement("xmp")',
|
||||
],
|
||||
HTMLQuoteElement: [
|
||||
'document.createElement("blockquote")',
|
||||
'document.createElement("q")',
|
||||
|
|
|
@ -8,11 +8,46 @@
|
|||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
document.documentElement.removeChild(document.body);
|
||||
document.fgColor = "green";
|
||||
document.bgColor = "green";
|
||||
document.linkColor = "green";
|
||||
document.vlinkColor = "green";
|
||||
document.alinkColor = "green";
|
||||
|
||||
var body = document.documentElement.removeChild(document.body);
|
||||
|
||||
// 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 = "";
|
||||
}, "getting document color attributes with no body");
|
||||
|
||||
test(function() {
|
||||
var body = document.documentElement.removeChild(document.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;
|
||||
}, "setting document color attributes with no body");
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>base element in about:blank document should resolve against its fallback base URI</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<iframe></iframe>
|
||||
<script>
|
||||
var t = async_test();
|
||||
addEventListener("load", t.step_func_done(function() {
|
||||
var doc = frames[0].document;
|
||||
var b = doc.createElement("base");
|
||||
b.setAttribute("href", "test");
|
||||
var newBaseValue = location.href.replace(/\/[^/]*$/, "/") + "test";
|
||||
assert_equals(b.href, newBaseValue);
|
||||
assert_equals(doc.baseURI, location.href);
|
||||
doc.head.appendChild(b);
|
||||
assert_equals(doc.baseURI, newBaseValue);
|
||||
}));
|
||||
</script>
|
|
@ -0,0 +1,12 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>base element with unparseable href should have .href getter return attr value</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script>
|
||||
test(function() {
|
||||
var b = document.createElement("base");
|
||||
b.setAttribute("href", "//test:test");
|
||||
assert_equals(b.href, "//test:test");
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,19 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>base element in srcdoc document should resolve against its fallback base URI</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<iframe srcdoc=""></iframe>
|
||||
<script>
|
||||
var t = async_test();
|
||||
addEventListener("load", t.step_func_done(function() {
|
||||
var doc = frames[0].document;
|
||||
var b = doc.createElement("base");
|
||||
b.setAttribute("href", "test");
|
||||
var newBaseValue = location.href.replace(/\/[^/]*$/, "/") + "test";
|
||||
assert_equals(b.href, newBaseValue);
|
||||
assert_equals(doc.baseURI, location.href);
|
||||
doc.head.appendChild(b);
|
||||
assert_equals(doc.baseURI, newBaseValue);
|
||||
}));
|
||||
</script>
|
|
@ -19,5 +19,7 @@ test(function() {
|
|||
assert_equals(list.contains(NaN), true); //"NaN"
|
||||
assert_equals(list.contains(+Infinity), true); //"Infinity"
|
||||
assert_equals(list.contains(-Infinity), false); //"-Infinity"
|
||||
assert_equals(list.supports("stylesheet"), true);
|
||||
assert_equals(list.supports("nosuchrelvalueever"), false);
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -13,7 +13,7 @@ test(function(){
|
|||
test(function(){
|
||||
var track = document.createElement('track');
|
||||
track.setAttribute('kind', 'invalid');
|
||||
assert_equals(track.kind, 'subtitles');
|
||||
assert_equals(track.kind, 'metadata');
|
||||
assert_equals(track.getAttribute('kind'), 'invalid');
|
||||
}, document.title + ' invalid value in content attribute');
|
||||
|
||||
|
@ -27,14 +27,14 @@ test(function(){
|
|||
test(function(){
|
||||
var track = document.createElement('track');
|
||||
track.setAttribute('kind', 'CAPT\u0130ONS');
|
||||
assert_equals(track.kind, 'subtitles');
|
||||
assert_equals(track.kind, 'metadata');
|
||||
assert_equals(track.getAttribute('kind'), 'CAPT\u0130ONS');
|
||||
}, document.title + ' content attribute with uppercase turkish I (with dot)');
|
||||
|
||||
test(function(){
|
||||
var track = document.createElement('track');
|
||||
track.setAttribute('kind', 'capt\u0131ons');
|
||||
assert_equals(track.kind, 'subtitles');
|
||||
assert_equals(track.kind, 'metadata');
|
||||
assert_equals(track.getAttribute('kind'), 'capt\u0131ons');
|
||||
}, document.title + ' content attribute with lowercase turkish i (dotless)');
|
||||
|
||||
|
@ -76,7 +76,7 @@ test(function(){
|
|||
test(function(){
|
||||
var track = document.createElement('track');
|
||||
track.setAttribute('kind', 'captions\u0000');
|
||||
assert_equals(track.kind, 'subtitles');
|
||||
assert_equals(track.kind, 'metadata');
|
||||
assert_equals(track.getAttribute('kind'), 'captions\u0000');
|
||||
}, document.title + ' content attribute "captions\\u0000"');
|
||||
|
||||
|
@ -126,21 +126,21 @@ test(function(){
|
|||
var track = document.createElement('track');
|
||||
track.kind = 'CAPT\u0130ONS';
|
||||
assert_equals(track.getAttribute('kind'), 'CAPT\u0130ONS');
|
||||
assert_equals(track.kind, 'subtitles');
|
||||
assert_equals(track.kind, 'metadata');
|
||||
}, document.title + ' setting IDL attribute with uppercase turkish I (with dot)');
|
||||
|
||||
test(function(){
|
||||
var track = document.createElement('track');
|
||||
track.kind = 'capt\u0131ons';
|
||||
assert_equals(track.getAttribute('kind'), 'capt\u0131ons');
|
||||
assert_equals(track.kind, 'subtitles');
|
||||
assert_equals(track.kind, 'metadata');
|
||||
}, document.title + ' setting IDL attribute with lowercase turkish I (dotless)');
|
||||
|
||||
test(function(){
|
||||
var track = document.createElement('track');
|
||||
track.kind = 'captions\u0000';
|
||||
assert_equals(track.getAttribute('kind'), 'captions\u0000');
|
||||
assert_equals(track.kind, 'subtitles');
|
||||
assert_equals(track.kind, 'metadata');
|
||||
}, document.title + ' setting IDL attribute with \\u0000');
|
||||
|
||||
</script>
|
||||
|
|
|
@ -26,6 +26,6 @@ test(function(){
|
|||
test(function(){
|
||||
var track = document.createElement('track');
|
||||
track.kind = 'captions\u0000';
|
||||
assert_equals(track.track.kind, 'subtitles');
|
||||
assert_equals(track.track.kind, 'metadata');
|
||||
}, document.title+', \\u0000');
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>Test some sanity behavior around iframe load/error events</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<body>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var obj = document.createElement("iframe");
|
||||
obj.onload = t.step_func_done(function(e){
|
||||
assert_true(obj.contentWindow instanceof Window, "The iframe element should represent a nested browsing context.")
|
||||
assert_equals(Object.getPrototypeOf(e).constructor, Event, "The load event should use the Event interface.");
|
||||
assert_true(e.isTrusted, "The load event should be a trusted event.");
|
||||
assert_false(e.cancelable, "The load event should not be a cancelable event.");
|
||||
assert_false(e.bubbles, "The load event should not be a bubble event.");
|
||||
assert_equals(e.target, obj, "The load event target should be the corresponding object element.");
|
||||
});
|
||||
|
||||
obj.onerror = t.step_func_done(function(e){
|
||||
assert_unreached("The error event should not be fired.");
|
||||
});
|
||||
|
||||
var url = URL.createObjectURL(new Blob([""], { type: "text/html" }));
|
||||
|
||||
obj.src = url;
|
||||
document.body.appendChild(obj);
|
||||
}, "load event of blob URL");
|
||||
|
||||
async_test(function(t) {
|
||||
var obj = document.createElement("iframe");
|
||||
obj.onload = t.step_func_done(function(e){
|
||||
assert_true(obj.contentWindow instanceof Window, "The object element should represent a nested browsing context.")
|
||||
assert_equals(Object.getPrototypeOf(e).constructor, Event, "The load event should use the Event interface.");
|
||||
assert_true(e.isTrusted, "The load event should be a trusted event.");
|
||||
assert_false(e.cancelable, "The load event should not be a cancelable event.");
|
||||
assert_false(e.bubbles, "The load event should not be a bubble event.");
|
||||
assert_equals(e.target, obj, "The load event target should be the corresponding object element.");
|
||||
});
|
||||
|
||||
obj.onerror = t.step_func_done(function(e){
|
||||
assert_unreached("The error event should not be fired.");
|
||||
});
|
||||
|
||||
document.body.appendChild(obj);
|
||||
}, "load event of initial about:blank");
|
||||
|
||||
</script>
|
||||
</body>
|
|
@ -89,8 +89,15 @@
|
|||
|
||||
<img src="/images/green-2x2.png" data-desc="inserted/removed children of img">
|
||||
|
||||
<picture><img src="/images/green-2x2.png" data-desc="picture is inserted"></picture><span></span>
|
||||
<picture><img src="/images/green-2x2.png" data-desc="picture is removed"></picture>
|
||||
<picture><img src="/images/green-2x2.png" data-desc="picture is inserted; img has src"></picture><span></span>
|
||||
<picture><img srcset="/images/green-2x2.png" data-desc="picture is inserted; img has srcset"></picture><span></span>
|
||||
<picture><source srcset="/images/green-2x2.png"><img src="/images/green-2x2.png" data-desc="picture is inserted; img has previous sibling source"></picture><span></span>
|
||||
<picture><img src="/images/green-2x2.png" data-desc="picture is inserted; img has following sibling source"><source srcset="/images/green-2x2.png"></picture><span></span>
|
||||
|
||||
<picture><img src="/images/green-2x2.png" data-desc="picture is removed; img has src"></picture>
|
||||
<picture><img srcset="/images/green-2x2.png" data-desc="picture is removed; img has srcset"></picture>
|
||||
<picture><source srcset="/images/green-2x2.png"><img src="/images/green-2x2.png" data-desc="picture is removed; img has previous sibling source"></picture>
|
||||
<picture><img src="/images/green-2x2.png" data-desc="picture is removed; img has following sibling source"><source srcset="/images/green-2x2.png"></picture>
|
||||
|
||||
<picture><img src="/images/green-2x2.png" data-desc="parent is picture, following img inserted"></picture>
|
||||
<picture><img src="/images/green-2x2.png" data-desc="parent is picture, following img removed"><img></picture>
|
||||
|
@ -352,11 +359,35 @@ onload = function() {
|
|||
}), 0);
|
||||
}, 'timeout');
|
||||
|
||||
t('picture is inserted', function(img) {
|
||||
t('picture is inserted; img has src', function(img) {
|
||||
img.parentNode.nextSibling.appendChild(img.parentNode);
|
||||
}, 'timeout');
|
||||
|
||||
t('picture is removed', function(img) {
|
||||
t('picture is inserted; img has srcset', function(img) {
|
||||
img.parentNode.nextSibling.appendChild(img.parentNode);
|
||||
}, 'timeout');
|
||||
|
||||
t('picture is inserted; img has previous sibling source', function(img) {
|
||||
img.parentNode.nextSibling.appendChild(img.parentNode);
|
||||
}, 'timeout');
|
||||
|
||||
t('picture is inserted; img has following sibling source', function(img) {
|
||||
img.parentNode.nextSibling.appendChild(img.parentNode);
|
||||
}, 'timeout');
|
||||
|
||||
t('picture is removed; img has src', function(img) {
|
||||
img.parentNode.parentNode.removeChild(img.parentNode);
|
||||
}, 'timeout');
|
||||
|
||||
t('picture is removed; img has srcset', function(img) {
|
||||
img.parentNode.parentNode.removeChild(img.parentNode);
|
||||
}, 'timeout');
|
||||
|
||||
t('picture is removed; img has previous sibling source', function(img) {
|
||||
img.parentNode.parentNode.removeChild(img.parentNode);
|
||||
}, 'timeout');
|
||||
|
||||
t('picture is removed; img has following sibling source', function(img) {
|
||||
img.parentNode.parentNode.removeChild(img.parentNode);
|
||||
}, 'timeout');
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
assert_true(c1_click_fired, "input event should fire after click event");
|
||||
assert_false(c1_change_fired, "input event should fire before change event");
|
||||
assert_true(e.bubbles, "event should bubble");
|
||||
assert_false(e.isTrusted, "click()-initiated event should not be trusted");
|
||||
assert_true(e.isTrusted, "click()-initiated event should be trusted");
|
||||
assert_false(e.cancelable, "event should not be cancelable");
|
||||
assert_true(checkbox1.checked, "checkbox is checked");
|
||||
assert_false(checkbox1.indeterminate, "checkbox is not indeterminate");
|
||||
|
@ -51,7 +51,7 @@
|
|||
assert_true(c1_click_fired, "change event should fire after click event");
|
||||
assert_true(c1_input_fired, "change event should fire after input event");
|
||||
assert_true(e.bubbles, "event should bubble")
|
||||
assert_false(e.isTrusted, "click()-initiated event should not be trusted");
|
||||
assert_true(e.isTrusted, "click()-initiated event should be trusted");
|
||||
assert_false(e.cancelable, "event should not be cancelable");
|
||||
assert_true(checkbox1.checked, "checkbox is checked");
|
||||
assert_false(checkbox1.indeterminate, "checkbox is not indeterminate");
|
||||
|
|
|
@ -0,0 +1,332 @@
|
|||
<!DOCTYPE html>
|
||||
<title>innerHTML in HTML</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
|
||||
<!-- test elments. Each has an expected innerHTML and outerHTML in an array in the <script>-->
|
||||
<div id="test" style="display:none">
|
||||
<span></span>
|
||||
<span><a></a></span>
|
||||
<span><a b=c></a></span>
|
||||
<span><a b='c'></a></span>
|
||||
<span><a b='&'></a></span>
|
||||
<span><a b=' '></a></span>
|
||||
<span><a b='"'></a></span>
|
||||
<span><a b="<"></a></span>
|
||||
<span><a b=">"></a></span>
|
||||
<span><svg xlink:href="a"></svg></span>
|
||||
<span><svg xmlns:svg="test"></svg></span>
|
||||
<span>a</span>
|
||||
<span>&</span>
|
||||
<span> </span>
|
||||
<span><</span>
|
||||
<span>></span>
|
||||
<span>"</span>
|
||||
<span><style><&></style></span>
|
||||
<span><script type="test"><&></script></span>
|
||||
<span><xmp><&></xmp></span>
|
||||
<span><iframe><&></iframe></span>
|
||||
<span><noembed><&></noembed></span>
|
||||
<span><noframes><&></noframes></span>
|
||||
<span><noscript><&></noscript></span>
|
||||
<span><!--data--></span>
|
||||
<span><a><b><c></c></b><d>e</d><f><g>h</g></f></a></span>
|
||||
<span b=c></span>
|
||||
</div>
|
||||
<!-- TODO: template element -->
|
||||
<script>
|
||||
|
||||
var test_data = document.getElementById("test").getElementsByTagName("span");
|
||||
var expected = [
|
||||
["", "<span></span>"],
|
||||
["<a></a>", "<span><a></a></span>"],
|
||||
["<a b=\"c\"></a>", "<span><a b=\"c\"></a></span>"],
|
||||
["<a b=\"c\"></a>", "<span><a b=\"c\"></a></span>"],
|
||||
["<a b=\"&\"></a>", "<span><a b=\"&\"></a></span>"],
|
||||
["<a b=\" \"></a>", "<span><a b=\" \"></a></span>"],
|
||||
["<a b=\""\"></a>", "<span><a b=\""\"></a></span>"],
|
||||
["<a b=\"<\"></a>", "<span><a b=\"<\"></a></span>"],
|
||||
["<a b=\">\"></a>", "<span><a b=\">\"></a></span>"],
|
||||
["<svg xlink:href=\"a\"></svg>", "<span><svg xlink:href=\"a\"></svg></span>"],
|
||||
["<svg xmlns:svg=\"test\"></svg>", "<span><svg xmlns:svg=\"test\"></svg></span>"],
|
||||
["a", "<span>a</span>"],
|
||||
["&", "<span>&</span>"],
|
||||
[" ", "<span> </span>"],
|
||||
["<", "<span><</span>"],
|
||||
[">", "<span>></span>"],
|
||||
["\"", "<span>\"</span>"],
|
||||
["<style><&></style>", "<span><style><&></style></span>"],
|
||||
["<script type=\"test\"><&><\/script>", "<span><script type=\"test\"><&><\/script></span>"],
|
||||
["<xmp><&></xmp>", "<span><xmp><&></xmp></span>"],
|
||||
["<iframe><&></iframe>", "<span><iframe><&></iframe></span>"],
|
||||
["<noembed><&></noembed>", "<span><noembed><&></noembed></span>"],
|
||||
["<noframes><&></noframes>", "<span><noframes><&></noframes></span>"],
|
||||
["<noscript><&></noscript>", "<span><noscript><&></noscript></span>"],
|
||||
["<!--data-->", "<span><!--data--></span>"],
|
||||
["<a><b><c></c></b><d>e</d><f><g>h</g></f></a>", "<span><a><b><c></c></b><d>e</d><f><g>h</g></f></a></span>"],
|
||||
["", "<span b=\"c\"></span>"]
|
||||
];
|
||||
|
||||
var dom_tests = [
|
||||
["Attribute in the XML namespace",
|
||||
function() {
|
||||
var span = document.createElement("span");
|
||||
var svg = document.createElement("svg");
|
||||
svg.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:foo", "test");
|
||||
span.appendChild(svg);
|
||||
return span;
|
||||
},
|
||||
'<svg xml:foo="test"></svg>',
|
||||
'<span><svg xml:foo="test"></svg></span>'],
|
||||
|
||||
["Attribute in the XML namespace with the prefix not set to xml:",
|
||||
function() {
|
||||
var span = document.createElement("span");
|
||||
var svg = document.createElement("svg");
|
||||
svg.setAttributeNS("http://www.w3.org/XML/1998/namespace", "abc:foo", "test");
|
||||
span.appendChild(svg);
|
||||
return span;
|
||||
},
|
||||
'<svg xml:foo="test"></svg>',
|
||||
'<span><svg xml:foo="test"></svg></span>'],
|
||||
|
||||
["Non-'xmlns' attribute in the xmlns namespace",
|
||||
function() {
|
||||
var span = document.createElement("span");
|
||||
var svg = document.createElement("svg");
|
||||
svg.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:foo", "test")
|
||||
span.appendChild(svg);
|
||||
return span;
|
||||
},
|
||||
'<svg xmlns:foo="test"></svg>',
|
||||
'<span><svg xmlns:foo="test"></svg></span>'],
|
||||
|
||||
["'xmlns' attribute in the xmlns namespace",
|
||||
function() {
|
||||
var span = document.createElement("span");
|
||||
var svg = document.createElement("svg");
|
||||
svg.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "test")
|
||||
span.appendChild(svg);
|
||||
return span;
|
||||
},
|
||||
'<svg xmlns="test"></svg>',
|
||||
'<span><svg xmlns="test"></svg></span>'],
|
||||
|
||||
["Attribute in non-standard namespace",
|
||||
function() {
|
||||
var span = document.createElement("span");
|
||||
var svg = document.createElement("svg");
|
||||
svg.setAttributeNS("fake_ns", "abc:def", "test")
|
||||
span.appendChild(svg);
|
||||
return span;
|
||||
},
|
||||
'<svg abc:def="test"></svg>',
|
||||
'<span><svg abc:def="test"></svg></span>'],
|
||||
|
||||
["<span> starting with U+000A",
|
||||
function() {
|
||||
var elem = document.createElement("span");
|
||||
elem.appendChild(document.createTextNode("\x0A"));
|
||||
return elem;
|
||||
},
|
||||
"\x0A",
|
||||
"<span>\x0A</span>"],
|
||||
|
||||
//TODO: Processing instructions
|
||||
]
|
||||
|
||||
var text_elements = ["pre", "textarea", "listing"];
|
||||
|
||||
var text_tests = [
|
||||
["<%text> context starting with U+000A",
|
||||
function(elem) {
|
||||
elem.appendChild(document.createTextNode("\x0A"));
|
||||
return elem;
|
||||
},
|
||||
"\x0A",
|
||||
"<%text>\x0A\x0A</%text>"],
|
||||
|
||||
["<%text> context not starting with U+000A",
|
||||
function(elem) {
|
||||
elem.appendChild(document.createTextNode("a\x0A"));
|
||||
return elem;
|
||||
},
|
||||
"a\x0A",
|
||||
"<%text>a\x0A</%text>"],
|
||||
|
||||
["<%text> non-context starting with U+000A",
|
||||
function(elem) {
|
||||
var span = document.createElement("span");
|
||||
elem.appendChild(document.createTextNode("\x0A"));
|
||||
span.appendChild(elem);
|
||||
return span;
|
||||
},
|
||||
"<%text>\x0A\x0A</%text>",
|
||||
"<span><%text>\x0A\x0A</%text></span>"],
|
||||
|
||||
["<%text> non-context not starting with U+000A",
|
||||
function(elem) {
|
||||
var span = document.createElement("span");
|
||||
elem.appendChild(document.createTextNode("a\x0A"));
|
||||
span.appendChild(elem);
|
||||
return span;
|
||||
},
|
||||
"<%text>a\x0A</%text>",
|
||||
"<span><%text>a\x0A</%text></span>"],
|
||||
]
|
||||
|
||||
var void_elements = [
|
||||
"area", "base", "basefont", "bgsound", "br", "col", "embed",
|
||||
"frame", "hr", "img", "input", "keygen", "link", "menuitem",
|
||||
"meta", "param", "source", "track", "wbr"
|
||||
];
|
||||
|
||||
var void_tests = [
|
||||
["Void context node",
|
||||
function (void_elem) {
|
||||
return void_elem;
|
||||
},
|
||||
"",
|
||||
"<%void>"
|
||||
],
|
||||
["void as first child with following siblings",
|
||||
function (void_elem) {
|
||||
var span = document.createElement("span");
|
||||
span.appendChild(void_elem);
|
||||
span.appendChild(document.createElement("a")).appendChild(document.createTextNode("test"));
|
||||
span.appendChild(document.createElement("b"))
|
||||
return span
|
||||
},
|
||||
"<%void><a>test</a><b></b>",
|
||||
"<span><%void><a>test</a><b></b></span>"
|
||||
],
|
||||
["void as second child with following siblings",
|
||||
function (void_elem) {
|
||||
var span = document.createElement("span");
|
||||
span.appendChild(document.createElement("a")).appendChild(document.createTextNode("test"));
|
||||
span.appendChild(void_elem);
|
||||
span.appendChild(document.createElement("b"))
|
||||
return span;
|
||||
},
|
||||
"<a>test</a><%void><b></b>",
|
||||
"<span><a>test</a><%void><b></b></span>"
|
||||
],
|
||||
["void as last child with preceding siblings",
|
||||
function (void_elem) {
|
||||
var span = document.createElement("span");
|
||||
span.appendChild(document.createElement("a")).appendChild(document.createTextNode("test"));
|
||||
span.appendChild(document.createElement("b"))
|
||||
span.appendChild(void_elem);
|
||||
return span;
|
||||
},
|
||||
"<a>test</a><b></b><%void>",
|
||||
"<span><a>test</a><b></b><%void></span>"
|
||||
],
|
||||
]
|
||||
|
||||
function cross_map(a1, a2, f) {
|
||||
var rv = [];
|
||||
a1.forEach(function(a1_elem) {
|
||||
a2.forEach(function(a2_elem) {
|
||||
rv.push(f(a1_elem, a2_elem));
|
||||
})
|
||||
});
|
||||
return rv;
|
||||
}
|
||||
|
||||
function innerHTML_test(func, elem, expected) {
|
||||
assert_equals(func(elem).innerHTML, expected);
|
||||
}
|
||||
|
||||
function outerHTML_test(func, elem, expected) {
|
||||
assert_equals(func(elem).outerHTML, expected);
|
||||
}
|
||||
|
||||
|
||||
function make_void(name) {
|
||||
var rv = document.createElement(name);
|
||||
rv.appendChild(document.createElement("a")).appendChild(document.createComment("abc"))
|
||||
rv.appendChild(document.createElement("b")).
|
||||
appendChild(document.createElement("c")).
|
||||
appendChild(document.createTextNode("abc"))
|
||||
return rv;
|
||||
}
|
||||
|
||||
function make_text(name) {
|
||||
return document.createElement(name);
|
||||
}
|
||||
|
||||
generate_tests(innerHTML_test,
|
||||
expected.map(function(item, i) {
|
||||
return ["innerHTML " + i + " " + expected[i][0],
|
||||
function() {return test_data[i]},
|
||||
null,
|
||||
item[0]];
|
||||
}))
|
||||
|
||||
generate_tests(outerHTML_test,
|
||||
expected.map(function(item, i) {
|
||||
return ["outerHTML " + i + " " + expected[i][1],
|
||||
function() {return test_data[i]},
|
||||
null,
|
||||
item[1]];
|
||||
}))
|
||||
|
||||
generate_tests(innerHTML_test,
|
||||
dom_tests.map(function(item) {
|
||||
return ["innerHTML " + item[0],
|
||||
item[1],
|
||||
null,
|
||||
item[2]];
|
||||
}))
|
||||
|
||||
generate_tests(outerHTML_test,
|
||||
dom_tests.map(function(item) {
|
||||
return ["outerHTML " + item[0],
|
||||
item[1],
|
||||
null,
|
||||
item[3]];
|
||||
}))
|
||||
|
||||
generate_tests(innerHTML_test,
|
||||
cross_map(text_tests, text_elements,
|
||||
function(test_data, elem_name) {
|
||||
var rv = ["innerHTML " + test_data[0].replace("%text", elem_name, "g"),
|
||||
test_data[1],
|
||||
document.createElement(elem_name),
|
||||
test_data[2].replace("%text", elem_name, "g")];
|
||||
return rv;
|
||||
}))
|
||||
|
||||
generate_tests(outerHTML_test,
|
||||
cross_map(text_tests, text_elements,
|
||||
function(test_data, elem_name) {
|
||||
var rv = ["outerHTML " + test_data[0].replace("%text", elem_name, "g"),
|
||||
test_data[1],
|
||||
document.createElement(elem_name),
|
||||
test_data[3].replace("%text", elem_name, "g")];
|
||||
return rv;
|
||||
}))
|
||||
|
||||
generate_tests(innerHTML_test,
|
||||
cross_map(void_tests, void_elements,
|
||||
function(test_data, elem_name) {
|
||||
var rv = ["innerHTML " + test_data[0] + " " + elem_name,
|
||||
test_data[1],
|
||||
make_void(elem_name),
|
||||
test_data[2].replace("%void", elem_name, "g")];
|
||||
return rv;
|
||||
}))
|
||||
|
||||
generate_tests(outerHTML_test,
|
||||
cross_map(void_tests, void_elements,
|
||||
function(test_data, elem_name) {
|
||||
var rv = ["outerHTML " + test_data[0] + " " + elem_name,
|
||||
test_data[1],
|
||||
make_void(elem_name),
|
||||
test_data[3].replace("%void", elem_name, "g")];
|
||||
return rv;
|
||||
}))
|
||||
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue