Update web-platform-tests to revision b7ee88243f64e6c7f2d00c163bd3bc501e4db7ef

This commit is contained in:
WPT Sync Bot 2018-02-06 20:08:49 -05:00
parent 804b4b3db6
commit a4b4c8e015
134 changed files with 2918 additions and 388 deletions

View file

@ -1,9 +1,12 @@
<!DOCTYPE html>
<html is="my-html">
<head>
<meta charset="utf-8">
<meta name="help" content="https://html.spec.whatwg.org/multipage/custom-elements.html#element-definition">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
</head>
<body is="my-body">
<div id="container"></div>
<script>
class MyA extends HTMLAnchorElement {
@ -667,15 +670,15 @@ let testData = [
{tag: 'bdi', klass: MyBdi},
{tag: 'bdo', klass: MyBdo},
{tag: 'blockquote', klass: MyBlockquote},
{tag: 'body', klass: MyBody, innerHTML: 'skip'},
{tag: 'body', klass: MyBody, parsing: 'document'},
{tag: 'br', klass: MyBr},
{tag: 'button', klass: MyButton},
{tag: 'canvas', klass: MyCanvas},
{tag: 'caption', klass: MyCaption, innerHTML: 'table'},
{tag: 'caption', klass: MyCaption, parsing: 'table'},
{tag: 'cite', klass: MyCite},
{tag: 'code', klass: MyCode},
{tag: 'col', klass: MyCol, innerHTML: 'table'},
{tag: 'colgroup', klass: MyColgroup, innerHTML: 'table'},
{tag: 'col', klass: MyCol, parsing: 'table'},
{tag: 'colgroup', klass: MyColgroup, parsing: 'table'},
{tag: 'data', klass: MyData},
{tag: 'dd', klass: MyDd},
{tag: 'del', klass: MyDel},
@ -700,7 +703,7 @@ let testData = [
{tag: 'header', klass: MyHeader},
{tag: 'hgroup', klass: MyHgroup},
{tag: 'hr', klass: MyHr},
{tag: 'html', klass: MyHtml, innerHTML: 'skip'},
{tag: 'html', klass: MyHtml, parsing: 'document'},
{tag: 'i', klass: MyI},
{tag: 'iframe', klass: MyIframe},
{tag: 'img', klass: MyImg},
@ -747,16 +750,16 @@ let testData = [
{tag: 'summary', klass: MySummary},
{tag: 'sup', klass: MySup},
{tag: 'table', klass: MyTable},
{tag: 'tbody', klass: MyTbody, innerHTML: 'table'},
{tag: 'td', klass: MyTd, innerHTML: 'table'},
{tag: 'tbody', klass: MyTbody, parsing: 'table'},
{tag: 'td', klass: MyTd, parsing: 'table'},
{tag: 'template', klass: MyTemplate},
{tag: 'textarea', klass: MyTextarea},
{tag: 'tfoot', klass: MyTfoot, innerHTML: 'table'},
{tag: 'th', klass: MyTh, innerHTML: 'table'},
{tag: 'thead', klass: MyThead, innerHTML: 'table'},
{tag: 'tfoot', klass: MyTfoot, parsing: 'table'},
{tag: 'th', klass: MyTh, parsing: 'table'},
{tag: 'thead', klass: MyThead, parsing: 'table'},
{tag: 'time', klass: MyTime},
{tag: 'title', klass: MyTitle},
{tag: 'tr', klass: MyTr, innerHTML: 'table'},
{tag: 'tr', klass: MyTr, parsing: 'table'},
{tag: 'track', klass: MyTrack},
{tag: 'u', klass: MyU},
{tag: 'ul', klass: MyUl},
@ -789,7 +792,7 @@ if (window.HTMLSlotElement) {
}});
}
for (t of testData) {
for (const t of testData) {
test(() => {
let name = 'my-' + t.tag;
customElements.define(name, t.klass, { extends: t.tag });
@ -804,11 +807,16 @@ for (t of testData) {
assert_equals(customized.constructor, t.klass);
}, `${t.tag}: document.createElement() should instantiate a customized built-in element`);
if (t.innerHTML == 'skip')
if (t.parsing == 'document') {
let test = async_test(`${t.tag}: document parser should instantiate a customized built-in element`);
window.addEventListener('load', test.step_func_done(() => {
assert_equals(document.querySelector(t.tag).constructor, t.klass);
}));
return;
}
test(() => {
let container = document.getElementById('container');
if (t.innerHTML == 'table') {
if (t.parsing == 'table') {
container.innerHTML = `<table><${t.tag} is="${name}" id="${name}">`;
} else {
container.innerHTML = `<${t.tag} is="${name}" id="${name}">`;
@ -821,3 +829,4 @@ for (t of testData) {
}
</script>
</body>
</html>

View file

@ -0,0 +1,90 @@
<!DOCTYPE html>
<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics-other.html#selector-defined">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe id="iframe"></iframe>
<script>
const testList = [
{ tag_name: 'div', defined: true },
{ tag_name: 'a-a', defined: false },
{ tag_name: 'font-face', defined: true },
{ tag_name: 'abbr', is: 'my-abbr', defined: false },
];
// Setup iframe to test the parser.
const neither = 'rgb(255, 0, 0)';
const defined = 'rgb(255, 165, 0)';
const not_defined = 'rgb(0, 0, 255)';
iframe.srcdoc = `<style>
* { color:${neither}; }
:defined { color:${defined}; }
:not(:defined) { color:${not_defined}; }
</style>`
+ testList.map(d => `<${d.tag_name}${d.is ? ' is=' + d.is : ''}></${d.tag_name}>`).join('');
setup({ explicit_done: true });
iframe.onload = () => {
const doc = iframe.contentDocument;
const doc_without_browsing_context = doc.implementation.createHTMLDocument();
for (const data of testList) {
// Test elements inserted by parser.
test_defined(data.defined, doc.getElementsByTagName(data.tag_name)[0],
`<${data.tag_name}${data.is ? ' is=' + data.is : ''}>`);
// Test DOM createElement() methods.
test_defined_for_createElement(data.defined, !data.defined, doc, data.tag_name, data.is);
// Documents without browsing context should behave the same.
test_defined_for_createElement(data.defined, false, doc_without_browsing_context, data.tag_name, data.is, 'Without browsing context: ');
}
done();
};
function test_defined_for_createElement(defined, should_test_change, doc, tag_name, is, description = '') {
let is_desc = is ? `, { is: "${is}" }` : '';
// Test document.createElement().
let element = is ? doc.createElement(tag_name, { is: is }) : doc.createElement(tag_name);
doc.body.appendChild(element);
test_defined(defined, element, `${description}createElement("${tag_name}"${is_desc})`);
// Test document.createElementNS().
let html_element = is ? doc.createElementNS('http://www.w3.org/1999/xhtml', tag_name, { is: is })
: doc.createElementNS('http://www.w3.org/1999/xhtml', tag_name);
doc.body.appendChild(html_element);
test_defined(defined, html_element, `${description}createElementNS("http://www.w3.org/1999/xhtml", "${tag_name}"${is_desc})`);
// If the element namespace is not HTML, it should be "uncustomized"; i.e., "defined".
let svg_element = is ? doc.createElementNS('http://www.w3.org/2000/svg', tag_name, { is: is })
: doc.createElementNS('http://www.w3.org/2000/svg', tag_name);
doc.body.appendChild(svg_element);
test_defined(true, svg_element, `${description}createElementNS("http://www.w3.org/2000/svg", "${tag_name}"${is_desc})`);
// Test ":defined" changes when the custom element was defined.
if (should_test_change) {
let w = doc.defaultView;
assert_false(!w, 'defaultView required to test change');
if (is) {
w.customElements.define(is, class extends w.HTMLElement {}, { extends: tag_name });
} else {
w.customElements.define(tag_name, class extends w.HTMLElement {
constructor() { super(); }
});
}
test_defined(true, element, `Upgraded ${description}createElement("${tag_name}"${is_desc})`);
test_defined(true, html_element, `Upgraded ${description}createElementNS("http://www.w3.org/1999/xhtml", "${tag_name}"${is_desc})`);
}
}
function test_defined(expected, element, description) {
test(() => {
assert_equals(element.matches(':defined'), expected, 'matches(":defined")');
assert_equals(element.matches(':not(:defined)'), !expected, 'matches(":not(:defined")');
const view = element.ownerDocument.defaultView;
if (!view)
return;
const style = view.getComputedStyle(element);
assert_equals(style.color, expected ? defined : not_defined, 'getComputedStyle');
}, `${description} should ${expected ? 'be' : 'not be'} :defined`);
}
</script>