Update web-platform-tests to revision 2332a6bd8ab3d47986492a44d7a0455dfb4ad823

This commit is contained in:
WPT Sync Bot 2019-08-04 10:26:10 +00:00
parent d2856ce8ae
commit c789859814
350 changed files with 5147 additions and 1855 deletions

View file

@ -0,0 +1,84 @@
<!DOCTYPE html>
<title>DocumentAndElementEventHandlers / clipboard events for MathML</title>
<link
rel="help"
href="https://mathml-refresh.github.io/mathml-core/#dom-and-javascript"
/>
<link
rel="help"
href="https://html.spec.whatwg.org/multipage/webappapis.html#documentandelementeventhandlers"
/>
<link
rel="help"
href="https://w3c.github.io/clipboard-apis/#clipboard-event-copy"
/>
<link
rel="help"
href="https://w3c.github.io/clipboard-apis/#clipboard-event-cut"
/>
<link
rel="help"
href="https://w3c.github.io/clipboard-apis/#clipboard-event-paste"
/>
<meta
name="assert"
content="MathMLElements incorporate a functional DocumentAndElementEventHandlers interface"
/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<math
oncopy="document.copyHappened = true"
oncut="document.cutHappened = true"
onpaste="document.pasteHappened = true"
>
<mi>E</mi>
</math>
<script>
const EVENTS = ["copy", "cut", "paste"];
const el = document.querySelector("math");
function addEventListenerTest(name) {
async_test(test => {
el.addEventListener(
name,
test.step_func_done(e => {
assert_true(
true,
"MathML Elements should be able to receive ${name} events"
);
})
);
const event = new ClipboardEvent(name, {
bubbles: true,
cancellable: true
});
el.dispatchEvent(event);
}, `math.addEventListener for ${name}`);
}
function evaluatedHandlerTest(name) {
const handlerName = "on" + name;
test(() => {
const compiledHandler = el[handlerName];
assert_equals(
typeof compiledHandler,
"function",
`The ${handlerName} property must be a function`
);
compiledHandler();
assert_true(
window[name + "Happened"],
"Calling the handler must run the code"
);
}, `${handlerName}: the content attribute must be compiled into a function as the corresponding property`);
}
EVENTS.forEach(name => {
addEventListenerTest(name);
evaluatedHandlerTest(name);
});
</script>

View file

@ -0,0 +1,57 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>MathML 'ElementCSSInlineStyle` Mixin Tests</title>
<link
rel="help"
href="https://mathml-refresh.github.io/mathml-core/#dom-and-javascript"
/>
<style>
math * {
background-color: red;
}
</style>
<meta
name="assert"
content="MathMLElements incorporate a functional ElementCSSInlineStyle interface"
/>
<script src="/mathml/support/mathml-fragments.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<span
>This tests the presence and functionality of features of the
`ElementCSSInlineStyle` interface for MathMLElements</span
>
<math></math>
<script>
let mathEl = document.querySelector("math");
test(function() {
mathEl.style.backgroundColor = "lime";
assert_equals(
getComputedStyle(mathEl).backgroundColor,
"rgb(0, 255, 0)",
"The applied background should be green."
);
}, `The <math> element style property should be present and be functional.`);
Object.keys(MathMLFragments).forEach(elName => {
mathEl.innerHTML = MathMLFragments[elName];
test(function() {
let el = FragmentHelper.element(mathEl);
el.style.backgroundColor = "blue";
assert_equals(
getComputedStyle(el).backgroundColor,
"rgb(0, 0, 255)",
"The applied background should be blue."
);
}, `The ${elName}'s style property should be present and be functional.`);
});
</script>
</body>
</html>

View file

@ -0,0 +1,114 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>MathML 'HTMLOrForeignElement` Mixin Tests</title>
<link
rel="help"
href="https://mathml-refresh.github.io/mathml-core/#dom-and-javascript"
/>
<style>
mi {
background-color: red;
}
:focus {
background-color: rgb(0, 255, 0);
}
</style>
<meta
name="assert"
content="MathMLElements incorporate a functional HTMLOrForeignElement interface"
/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body tabindex="-1">
<span tabindex="-1"
>This tests the presence and functionality of features of
`HTMLOrForeignElement` (currently `HTMLOrSVGElement`)</span
>
<math tabindex="-1">
<mi>E</mi>
</math>
</body>
<script>
// spot check the functionality of several interfaces
let el = document.querySelector("mi");
let mathEl = document.querySelector("math");
// this really belongs in
// https://github.com/web-platform-tests/wpt/blob/master/html/dom/elements/global-attributes/dataset.html
// it is here tentatively
test(function() {
var mathml = document.createElementNS(
"http://www.w3.org/1998/Math/MathML",
"math"
);
assert_true(mathml.dataset instanceof DOMStringMap);
}, "MathML elements should have a .dataset");
// exercise some basic tests on .dataset
test(function() {
assert_equals(
Object.keys(el.dataset).toString(),
"",
"The .dataset property should be present"
);
el.setAttribute("data-one", "x");
el.setAttribute("data-two", "y");
assert_equals(
el.dataset.one,
"x",
'.one should be "x" after setting the data-one attribute'
);
assert_equals(
el.dataset.two,
"y",
'.one should be "y" after setting the data-two attribute'
);
el.dataset.one = "o";
assert_equals(
el.getAttribute("data-one"),
"o",
'the data-one attribute should reflect a change to dataset.one and contain "o"'
);
}, "The dataset property should be present and be functional.");
test(function() {
assert_equals(mathEl.tabIndex, -1);
}, "MathML elements should have a tabIndex property");
promise_test(function() {
function focus() {
mathEl.focus();
return Promise.resolve();
}
return focus().then(() => {
assert_equals(
getComputedStyle(mathEl).backgroundColor,
"rgb(0, 255, 0)",
"MathML elements with tabindex=-1 should be programmatically focusable and apply :focus"
);
});
}, "MathML elements should work with focus predictably");
promise_test(function() {
function blur() {
mathEl.blur();
return Promise.resolve();
}
return blur().then(() => {
assert_equals(
getComputedStyle(mathEl).backgroundColor,
"rgba(0, 0, 0, 0)",
"MathML elements with tabindex=-1 be programmatically blur() able"
);
});
}, "MathML elements should work with blur predictably");
</script>
</html>

View file

@ -0,0 +1,108 @@
<!DOCTYPE html>
<title>MathMLElement GlobalEventHandlers</title>
<link rel="author" title="Brian Kardell" href="mailto:bkardell@igalia.com" />
<link
rel="help"
href="https://mathml-refresh.github.io/mathml-core/#dom-and-javascript"
/>
<link
rel="help"
href="https://html.spec.whatwg.org/multipage/#event-handler-idl-attributes"
/>
<link
rel="help"
href="https://html.spec.whatwg.org/multipage/#event-handler-content-attributes"
/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script>
"use strict";
setup({ explicit_done: true });
// basic pattern lifted from /html/webappapis/scripting/events/event-handler-all-global-events.html
fetch("/interfaces/html.idl")
.then(res => res.text())
.then(htmlIDL => {
const parsedHTMLIDL = WebIDL2.parse(htmlIDL);
const globalEventHandlers = parsedHTMLIDL.find(
idl => idl.name === "GlobalEventHandlers"
);
// onerror is too special
const names = globalEventHandlers.members
.map(member => member.name)
.filter(name => name !== "onerror");
for (const name of names) {
const withoutOn = name.substring(2);
test(() => {
const location = MathMLElement.prototype;
assert_true(
location.hasOwnProperty(name),
`${location.constructor.name} has an own property named "${name}"`
);
assert_false(
name in Element.prototype,
`Element.prototype must not contain a "${name}" property`
);
}, `${name}: must be on the appropriate locations for GlobalEventHandlers`);
test(() => {
const location = document.createElementNS(
"http://www.w3.org/1998/Math/MathML",
"math"
);
assert_equals(
location[name],
null,
`The default value of the property is null for a ${
location.constructor.name
} instance`
);
}, `${name}: the default value must be null`);
test(() => {
const el = document.createElementNS(
"http://www.w3.org/1998/Math/MathML",
"math"
);
el.setAttribute(name, `window.${name}Happened = true;`);
const compiledHandler = el[name];
assert_equals(
typeof compiledHandler,
"function",
`The ${name} property must be a function`
);
compiledHandler();
assert_true(
window[name + "Happened"],
"Calling the handler must run the code"
);
}, `${name}: the content attribute must be compiled into a function as the corresponding property`);
test(() => {
const element = document.createElementNS(
"http://www.w3.org/1998/Math/MathML",
"math"
);
element[name] = e => {
assert_equals(
e.currentTarget,
element,
"The event must be fired at the <math> element"
);
};
element.dispatchEvent(new Event(withoutOn));
}, `${name}: dispatching an Event at a <math> element must trigger element.${name}`);
}
done();
});
</script>