Commit 5ae96906 authored by Chromium WPT Sync's avatar Chromium WPT Sync Committed by Commit Bot

Import wpt@49dfd42d43a2927760e0fcc8cdb5b2626fafde67

Using wpt-import in Chromium d30014c6.
With Chromium commits locally applied on WPT:
250461b3 "Worker: Register a service worker just once for worker subresource interception tests"
bf4ad57e "Experimental CookieStore API: some additional browser-side validation"
ff9a2993 "[WPT/common/security-features] Sort keys of test config JSONs"


Note to sheriffs: This CL imports external tests and adds
expectations for those tests; if this CL is large and causes
a few new failures, please fix the failures by adding new
lines to TestExpectations rather than reverting. See:
https://chromium.googlesource.com/chromium/src/+/master/docs/testing/web_platform_tests.md

Directory owners for changes in this CL:
foolip@chromium.org, lpz@chromium.org, robertma@chromium.org:
  external/wpt/tools

NOAUTOREVERT=true
TBR=robertma

No-Export: true
Change-Id: I242de766bb1b5688fe11996db84dabbc6057f8f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1719105Reviewed-by: default avatarWPT Autoroller <wpt-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Commit-Queue: WPT Autoroller <wpt-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Cr-Commit-Position: refs/heads/master@{#681074}
parent e4a42cfc
// GENERATED CONTENT - DO NOT EDIT
// Content was automatically extracted by Reffy into reffy-reports
// (https://github.com/tidoust/reffy-reports)
// Source: Largest Contentful Paint (https://wicg.github.io/largest-contentful-paint/)
interface LargestContentfulPaint : PerformanceEntry {
readonly attribute DOMHighResTimeStamp renderTime;
readonly attribute DOMHighResTimeStamp loadTime;
readonly attribute unsigned long size;
readonly attribute DOMString id;
readonly attribute DOMString url;
readonly attribute Element? element;
};
...@@ -23,8 +23,8 @@ callback PerformanceObserverCallback = void (PerformanceObserverEntryList entrie ...@@ -23,8 +23,8 @@ callback PerformanceObserverCallback = void (PerformanceObserverEntryList entrie
PerformanceObserver observer); PerformanceObserver observer);
[Constructor(PerformanceObserverCallback callback), Exposed=(Window,Worker)] [Constructor(PerformanceObserverCallback callback), Exposed=(Window,Worker)]
interface PerformanceObserver { interface PerformanceObserver {
void observe(optional PerformanceObserverInit options); void observe (optional PerformanceObserverInit options = {});
void disconnect(); void disconnect ();
PerformanceEntryList takeRecords(); PerformanceEntryList takeRecords();
[SameObject] static readonly attribute FrozenArray<DOMString> supportedEntryTypes; [SameObject] static readonly attribute FrozenArray<DOMString> supportedEntryTypes;
}; };
......
...@@ -4,23 +4,23 @@ ...@@ -4,23 +4,23 @@
// Source: User Timing Level 3 (https://w3c.github.io/user-timing/) // Source: User Timing Level 3 (https://w3c.github.io/user-timing/)
dictionary PerformanceMarkOptions { dictionary PerformanceMarkOptions {
any detail; any detail;
DOMHighResTimeStamp startTime; DOMHighResTimeStamp startTime;
}; };
dictionary PerformanceMeasureOptions { dictionary PerformanceMeasureOptions {
any detail; any detail;
(DOMString or DOMHighResTimeStamp) start; (DOMString or DOMHighResTimeStamp) start;
DOMHighResTimeStamp duration; DOMHighResTimeStamp duration;
(DOMString or DOMHighResTimeStamp) end; (DOMString or DOMHighResTimeStamp) end;
}; };
partial interface Performance { partial interface Performance {
PerformanceMark mark(DOMString markName, optional PerformanceMarkOptions markOptions = {}); PerformanceMark mark(DOMString markName, optional PerformanceMarkOptions markOptions = {});
void clearMarks(optional DOMString markName); void clearMarks(optional DOMString markName);
PerformanceMeasure measure(DOMString measureName, optional (DOMString or PerformanceMeasureOptions) startOrMeasureOptions = {}, optional DOMString endMark); PerformanceMeasure measure(DOMString measureName, optional (DOMString or PerformanceMeasureOptions) startOrMeasureOptions = {}, optional DOMString endMark);
void clearMeasures(optional DOMString measureName); void clearMeasures(optional DOMString measureName);
}; };
[Exposed=(Window,Worker), [Exposed=(Window,Worker),
Constructor(DOMString markName, optional PerformanceMarkOptions markOptions)] Constructor(DOMString markName, optional PerformanceMarkOptions markOptions)]
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
// (https://github.com/tidoust/reffy-reports) // (https://github.com/tidoust/reffy-reports)
// Source: Web Share API - Level 1 (https://wicg.github.io/web-share/) // Source: Web Share API - Level 1 (https://wicg.github.io/web-share/)
partial interface Navigator {
[SecureContext] Promise<void> share(optional ShareData data = {});
};
dictionary ShareData { dictionary ShareData {
USVString title; USVString title;
USVString text; USVString text;
......
<!doctype html>
<title>Largest Contentful Paint IDL tests</title>
<link rel="help" href="https://wicg.github.io/largest-contentful-paint/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
<script>
'use strict';
idl_test(
['largest-contentful-paint'],
['performance-timeline', 'dom'],
async (idl_array, t) => {
idl_array.add_objects({
LargestContentfulPaint: ['lcp']
});
window.lcp = await new Promise((resolve, reject) => {
const observer = new PerformanceObserver(entryList => {
resolve(entryList.getEntries()[0]);
});
observer.observe({type: 'largest-contentful-paint', buffered: true});
t.step_timeout(() => reject('Timed out waiting for LargestContentfulPaint entry'), 3000);
});
}
);
</script>
<!-- a contentful element to observe -->
<img src=/images/green-100x50.png>
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Largest Contentful Paint: observe image.</title>
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function (t) {
if (!window.LargestContentfulPaint) {
assert_unreached("LargestContentfulPaint is not implemented");
}
const beforeRender = performance.now();
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
const entry = entryList.getEntries()[0];
assert_equals(entry.entryType, 'largest-contentful-paint');
assert_greater_than_equal(entry.renderTime, beforeRender,
'The rendering timestamp should occur after script starts running.');
assert_greater_than_equal(performance.now(), entry.renderTime,
'The rendering timestamp should occur before the entry is dispatched to the observer.');
assert_equals(entry.startTime, 0);
assert_equals(entry.duration, 0);
// blue.png is 133 x 106.
assert_equals(entry.size, 14098);
assert_equals(entry.id, 'image_id');
// 25 is the length of "largest-contentful-paint/".
const index = window.location.href.lastIndexOf('/') - 25;
const pathname = window.location.href.substring(0, index) + '/images/blue.png';
assert_equals(entry.url, pathname);
assert_greater_than(entry.loadTime, beforeRender,
'The load timestamp should occur after script starts running.');
assert_less_than(entry.loadTime, entry.renderTime,
'The load timestamp should occur before the render timestamp.')
assert_equals(entry.element, document.getElementById('image_id'));
})
);
observer.observe({type: 'largest-contentful-paint', buffered: true});
}, 'Same-origin image after a JS initiated scroll event is observable.');
document.body.dispatchEvent(new Event('scroll'));
const image = new Image();
image.id = 'image_id';
image.src = '/images/blue.png';
document.body.appendChild(image);
</script>
</body>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Embellished operators</title>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#embellished-operators">
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#definition-of-space-like-elements">
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#layout-of-mrow">
<meta name="assert" content="Verify definition of embellished operators">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/feature-detection.js"></script>
<style>
/* Default spacing of operator 'X' is 0.2777777777777778em so quite different
from the measured/specified 0em and 1em. */
math, math * {
font: 25px/1 Ahem;
}
mn {
color: black;
}
.testedElement mo {
color: yellow !important;
}
.testedElement, .testedElement * {
color: blue !important;
background: blue !important;
}
</style>
<script>
function spaceBeforeElement(id) {
var element = document.getElementById(id);
var mnBefore = element.previousElementSibling;
return element.getBoundingClientRect().left - mnBefore.getBoundingClientRect().right;
}
function spaceBeforeCoreOperator(id) {
var element = document.getElementById(id);
var coreMo = element.getElementsByTagName("mo")[0];
return coreMo.getBoundingClientRect().left - element.getBoundingClientRect().left;
}
setup({ explicit_done: true });
window.addEventListener("load", runTests);
function runTests() {
var epsilon = 1;
var emToPx = 25;
["mrow", "mstyle", "mphantom", "mpadded"].forEach(tag => {
test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBeforeElement(`${tag}-op`), 2 * emToPx, epsilon);
assert_approx_equals(spaceBeforeCoreOperator(`${tag}-op`), 0, epsilon);
}, `${tag} (embellished operator)`);
test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBeforeElement(`${tag}-nonop`), 0, epsilon);
assert_approx_equals(spaceBeforeCoreOperator(`${tag}-nonop`), 2 * emToPx, epsilon);
}, `${tag} (not embellished operator)`);
});
done();
}
</script>
</head>
<body>
<div id="log"></div>
<p>
<math>
<mn>X</mn>
<mrow id="mrow-op" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mtext class="space-like">X</mtext>
</mrow>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mrow id="mrow-nonop" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn> <!-- "mn" is not space-like -->
</mrow>
<mn>X</mn>
</math>
</p>
<!-- mstyle is an embellished operator if its children consist
of one embellished operator and zero or more space-like elements. -->
<p>
<math>
<mn>X</mn>
<mstyle id="mstyle-op" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
</mstyle>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mstyle id="mstyle-nonop" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn> <!-- "mn" is not space-like -->
</mstyle>
<mn>X</mn>
</math>
</p>
<!-- mphantom is an embellished operator if its children consist
of one embellished operator and zero or more space-like elements. -->
<p>
<math>
<mn>X</mn>
<mphantom id="mphantom-op" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
</mphantom>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mphantom id="mphantom-nonop" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn> <!-- "mn" is not space-like -->
</mphantom>
<mn>X</mn>
</math>
</p>
<!-- mpadded is an embellished operator if its children consist
of one embellished operator and zero or more space-like elements. -->
<p>
<math>
<mn>X</mn>
<mpadded id="mpadded-op" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
</mpadded>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mpadded id="mpadded-nonop" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn> <!-- "mn" is not space-like -->
</mpadded>
<mn>X</mn>
</math>
</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Embellished operators</title>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#embellished-operators">
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#definition-of-space-like-elements">
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#layout-of-mrow">
<meta name="assert" content="Verify definition of embellished operators">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/feature-detection.js"></script>
<style>
/* Default spacing of operator 'X' is 0.2777777777777778em so quite different
from the measured/specified 0em and 1em. */
math, math * {
font: 25px/1 Ahem;
}
mn {
color: black;
}
mtext.space-like {
color: lightblue !important;
}
.testedElement mo {
color: yellow !important;
}
.testedElement, .testedElement * {
color: blue !important;
background: blue !important;
}
</style>
<script>
function spaceBeforeElement(element) {
var mnBefore = element.previousElementSibling;
return element.getBoundingClientRect().left - mnBefore.getBoundingClientRect().right;
}
setup({ explicit_done: true });
window.addEventListener("load", runTests);
function runTests() {
var epsilon = 1;
var emToPx = 25;
["msub", "msup", "msubsup", "munder", "mover", "munderover",
"mmultiscripts", "mfrac", "maction", "semantics"].forEach(tag => {
test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
var element = document.getElementsByTagName(tag)[0];
assert_approx_equals(spaceBeforeElement(element), 2 * emToPx, epsilon);
}, `${tag} (embellished operator)`);
test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
var element = document.getElementsByTagName(tag)[1];
assert_approx_equals(spaceBeforeElement(element), 0, epsilon);
}, `${tag} (not embellished operator)`);
});
done();
}
</script>
</head>
<body>
<div id="log"></div>
<!-- <msub>, <msup>, <msubsup>, <munder>, <mover>, <munderover>,
<mmultiscripts>, <mfrac>, <semantics> or <maction> are embellished
operators if their first child exists and is an embellished operator -->
<p>
<math>
<mn>X</mn>
<msub class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
</msub>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<msup class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
</msup>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<msubsup class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
<mn>X</mn>
</msubsup>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<munder class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
</munder>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mover class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
</mover>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<munderover class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
</munderover>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mmultiscripts class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
<mn>X</mn>
<mn>X</mn>
<mn>X</mn>
</mmultiscripts>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mfrac class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
</mfrac>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<maction class="testedElement" actiontype="statusline">
<mo lspace="2em" rspace="0em">X</mo>
<mn>STATUS MESSAGE</mn>
</maction>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<semantics class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<annotation>TEXT ANNOTATION</annotation>
<mn>X</mn>
</semantics>
<mn>X</mn>
</math>
</p>
<!-- <msub>, <msup>, <msubsup>, <munder>, <mover>, <munderover>,
<mmultiscripts>, <mfrac>, <semantics> or <maction> are not embellished
operators if their first child is not an embellished operator -->
<p>
<math>
<mn>X</mn>
<msub class="testedElement">
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
</msub>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<msup class="testedElement">
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
</msup>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<msubsup class="testedElement">
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
</msubsup>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<munder class="testedElement">
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
</munder>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mover class="testedElement">
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
</mover>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<munderover class="testedElement">
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
</munderover>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mmultiscripts class="testedElement">
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
<mn>X</mn>
<mn>X</mn>
</mmultiscripts>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mfrac class="testedElement">
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
</mfrac>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<maction class="testedElement" actiontype="statusline">
<mn>X</mn>
<mo lspace="2em" rspace="0em">STATUS MESSAGE</mo>
</maction>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<semantics class="testedElement">
<mrow>
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
</mrow>
<annotation>TEXT ANNOTATION</annotation>
</semantics>
<mn>X</mn>
</math>
</p>
</body>
</html>
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<meta name="assert" content="Verify definition of space-like elements"> <meta name="assert" content="Verify definition of space-like elements">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/feature-detection.js"></script>
<style> <style>
/* Default spacing of operator 'X' is 0.2777777777777778em so quite different /* Default spacing of operator 'X' is 0.2777777777777778em so quite different
from the measured/specified 0em and 1em. */ from the measured/specified 0em and 1em. */
...@@ -48,51 +49,61 @@ ...@@ -48,51 +49,61 @@
var emToPx = 25; var emToPx = 25;
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("mtext"), emToPx, epsilon); assert_approx_equals(spaceBefore("mtext"), emToPx, epsilon);
assert_approx_equals(spaceAfter("mtext"), emToPx, epsilon); assert_approx_equals(spaceAfter("mtext"), emToPx, epsilon);
}, "mtext is space-like"); }, "mtext is space-like");
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("mspace"), emToPx, epsilon); assert_approx_equals(spaceBefore("mspace"), emToPx, epsilon);
assert_approx_equals(spaceAfter("mspace"), emToPx, epsilon); assert_approx_equals(spaceAfter("mspace"), emToPx, epsilon);
}, "mspace is space-like"); }, "mspace is space-like");
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("mrow1"), emToPx, epsilon); assert_approx_equals(spaceBefore("mrow1"), emToPx, epsilon);
assert_approx_equals(spaceAfter("mrow1"), emToPx, epsilon); assert_approx_equals(spaceAfter("mrow1"), emToPx, epsilon);
}, "space-like mrow"); }, "space-like mrow");
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("mrow2"), 0, epsilon); assert_approx_equals(spaceBefore("mrow2"), 0, epsilon);
assert_approx_equals(spaceAfter("mrow2"), 2 * emToPx, epsilon); assert_approx_equals(spaceAfter("mrow2"), 2 * emToPx, epsilon);
}, "non-space-like mrow"); }, "non-space-like mrow");
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("mstyle1"), emToPx, epsilon); assert_approx_equals(spaceBefore("mstyle1"), emToPx, epsilon);
assert_approx_equals(spaceAfter("mstyle1"), emToPx, epsilon); assert_approx_equals(spaceAfter("mstyle1"), emToPx, epsilon);
}, "space-like mstyle"); }, "space-like mstyle");
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("mstyle2"), 0, epsilon); assert_approx_equals(spaceBefore("mstyle2"), 0, epsilon);
assert_approx_equals(spaceAfter("mstyle2"), 2 * emToPx, epsilon); assert_approx_equals(spaceAfter("mstyle2"), 2 * emToPx, epsilon);
}, "non-space-like mstyle"); }, "non-space-like mstyle");
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("mphantom1"), emToPx, epsilon); assert_approx_equals(spaceBefore("mphantom1"), emToPx, epsilon);
assert_approx_equals(spaceAfter("mphantom1"), emToPx, epsilon); assert_approx_equals(spaceAfter("mphantom1"), emToPx, epsilon);
}, "space-like mphantom"); }, "space-like mphantom");
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("mphantom2"), 0, epsilon); assert_approx_equals(spaceBefore("mphantom2"), 0, epsilon);
assert_approx_equals(spaceAfter("mphantom2"), 2 * emToPx, epsilon); assert_approx_equals(spaceAfter("mphantom2"), 2 * emToPx, epsilon);
}, "non-space-like mphantom"); }, "non-space-like mphantom");
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("mpadded1"), emToPx, epsilon); assert_approx_equals(spaceBefore("mpadded1"), emToPx, epsilon);
assert_approx_equals(spaceAfter("mpadded1"), emToPx, epsilon); assert_approx_equals(spaceAfter("mpadded1"), emToPx, epsilon);
}, "space-like mpadded"); }, "space-like mpadded");
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("mpadded2"), 0, epsilon); assert_approx_equals(spaceBefore("mpadded2"), 0, epsilon);
assert_approx_equals(spaceAfter("mpadded2"), 2 * emToPx, epsilon); assert_approx_equals(spaceAfter("mpadded2"), 2 * emToPx, epsilon);
}, "non-space-like mpadded"); }, "non-space-like mpadded");
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<meta name="assert" content="Verify definition of space-like elements"> <meta name="assert" content="Verify definition of space-like elements">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/feature-detection.js"></script>
<style> <style>
/* Default spacing of operator 'X' is 0.2777777777777778em so quite different /* Default spacing of operator 'X' is 0.2777777777777778em so quite different
from the measured/specified 0em and 1em. */ from the measured/specified 0em and 1em. */
...@@ -48,31 +49,37 @@ ...@@ -48,31 +49,37 @@
var emToPx = 25; var emToPx = 25;
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("maction1"), emToPx, epsilon); assert_approx_equals(spaceBefore("maction1"), emToPx, epsilon);
assert_approx_equals(spaceAfter("maction1"), emToPx, epsilon); assert_approx_equals(spaceAfter("maction1"), emToPx, epsilon);
}, "space-like maction"); }, "space-like maction");
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("maction2"), 0, epsilon); assert_approx_equals(spaceBefore("maction2"), 0, epsilon);
assert_approx_equals(spaceAfter("maction2"), 2 * emToPx, epsilon); assert_approx_equals(spaceAfter("maction2"), 2 * emToPx, epsilon);
}, "non-space like maction (no first child)"); }, "non-space like maction (no first child)");
test(function() { test(function() {
assert_approx_equals(spaceBefore("maction3"), 0, epsilon); assert_approx_equals(spaceBefore("maction3"), 0, epsilon);
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceAfter("maction3"), 2 * emToPx, epsilon); assert_approx_equals(spaceAfter("maction3"), 2 * emToPx, epsilon);
}, "non-space like maction (first child not space-like)"); }, "non-space like maction (first child not space-like)");
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("semantics1"), emToPx, epsilon); assert_approx_equals(spaceBefore("semantics1"), emToPx, epsilon);
assert_approx_equals(spaceAfter("semantics1"), emToPx, epsilon); assert_approx_equals(spaceAfter("semantics1"), emToPx, epsilon);
}, "space-like semantics"); }, "space-like semantics");
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("semantics2"), 0, epsilon); assert_approx_equals(spaceBefore("semantics2"), 0, epsilon);
assert_approx_equals(spaceAfter("semantics2"), 2 * emToPx, epsilon); assert_approx_equals(spaceAfter("semantics2"), 2 * emToPx, epsilon);
}, "non-space like semantics (no first child)"); }, "non-space like semantics (no first child)");
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("semantics3"), 0, epsilon); assert_approx_equals(spaceBefore("semantics3"), 0, epsilon);
assert_approx_equals(spaceAfter("semantics3"), 2 * emToPx, epsilon); assert_approx_equals(spaceAfter("semantics3"), 2 * emToPx, epsilon);
}, "non-space like semantics (first child not space-like)"); }, "non-space like semantics (first child not space-like)");
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<meta name="assert" content="Verify definition of space-like elements"> <meta name="assert" content="Verify definition of space-like elements">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/feature-detection.js"></script>
<style> <style>
/* Default spacing of operator 'X' is 0.2777777777777778em so quite different /* Default spacing of operator 'X' is 0.2777777777777778em so quite different
from the measured/specified 0em and 1em. */ from the measured/specified 0em and 1em. */
...@@ -47,6 +48,7 @@ ...@@ -47,6 +48,7 @@
Array.from(document.querySelectorAll(".testedElement")).forEach(el => { Array.from(document.querySelectorAll(".testedElement")).forEach(el => {
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore(el), 0, epsilon); assert_approx_equals(spaceBefore(el), 0, epsilon);
assert_approx_equals(spaceAfter(el), 2 * emToPx, epsilon); assert_approx_equals(spaceAfter(el), 2 * emToPx, epsilon);
}, `${el.tagName} is not space-like`); }, `${el.tagName} is not space-like`);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<meta name="assert" content="Verify definition of space-like elements"> <meta name="assert" content="Verify definition of space-like elements">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/feature-detection.js"></script>
<style> <style>
/* Default spacing of operator 'X' is 0.2777777777777778em so quite different /* Default spacing of operator 'X' is 0.2777777777777778em so quite different
from the measured/specified 0em and 1em. */ from the measured/specified 0em and 1em. */
...@@ -48,11 +49,13 @@ ...@@ -48,11 +49,13 @@
var emToPx = 25; var emToPx = 25;
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("complex1"), emToPx, epsilon); assert_approx_equals(spaceBefore("complex1"), emToPx, epsilon);
assert_approx_equals(spaceAfter("complex1"), emToPx, epsilon); assert_approx_equals(spaceAfter("complex1"), emToPx, epsilon);
}, "complex space-like subtree"); }, "complex space-like subtree");
test(function() { test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBefore("complex2"), 0, epsilon); assert_approx_equals(spaceBefore("complex2"), 0, epsilon);
assert_approx_equals(spaceAfter("complex2"), 2 * emToPx, epsilon); assert_approx_equals(spaceAfter("complex2"), 2 * emToPx, epsilon);
}, "complex non-space-like subtree"); }, "complex non-space-like subtree");
......
...@@ -4,12 +4,28 @@ ...@@ -4,12 +4,28 @@
var MathMLFeatureDetection = { var MathMLFeatureDetection = {
has_mspace: function() { has_mspace: function() {
if (!this.hasOwnProperty("_has_mspace")) { if (!this.hasOwnProperty("_has_mspace")) {
document.body.insertAdjacentHTML("beforeend", "<math><mspace width='20px'></mspace></math>"); document.body.insertAdjacentHTML("beforeend", "<math><mspace></mspace><mspace width='20px'></mspace></math>");
var math = document.body.lastElementChild; var math = document.body.lastElementChild;
// The width attribute will add 20px per MathML and none if not supported.
this._has_mspace = this._has_mspace =
math.lastChild.getBoundingClientRect().width -
math.firstChild.getBoundingClientRect().width > 10; math.firstChild.getBoundingClientRect().width > 10;
document.body.removeChild(math); document.body.removeChild(math);
} }
return this._has_mspace; return this._has_mspace;
},
has_operator_spacing: function() {
if (!this.hasOwnProperty("_has_operator_spacing")) {
document.body.insertAdjacentHTML("beforeend", "<math><mrow><mn>1</mn><mo lspace='0px' rspace='0px'>+</mo><mn>2</mn><mo lspace='8px' rspace='8px'>+</mo><mn>3</mn></mspace></mrow></math>");
var math = document.body.lastElementChild;
var mo = math.getElementsByTagName("mo");
// lspace/rspace will add 16px per MathML and none if not supported.
this._has_operator_spacing =
mo[1].getBoundingClientRect().width -
mo[0].getBoundingClientRect().width > 10;
document.body.removeChild(math);
}
return this._has_operator_spacing;
} }
}; };
flake8==3.7.7 flake8==3.7.8
pycodestyle==2.5.0 pycodestyle==2.5.0
pyflakes==2.1.1 pyflakes==2.1.1
pep8-naming==0.8.2 pep8-naming==0.8.2
mypy==0.711 mypy==0.720
mypy-extensions==0.4.1 mypy-extensions==0.4.1
typed-ast==1.4.0 typed-ast==1.4.0
...@@ -13,6 +13,7 @@ commands = pytest {posargs} ...@@ -13,6 +13,7 @@ commands = pytest {posargs}
passenv = passenv =
HYPOTHESIS_PROFILE HYPOTHESIS_PROFILE
PY_COLORS
[testenv:py27-flake8] [testenv:py27-flake8]
deps = -rrequirements_flake8.txt deps = -rrequirements_flake8.txt
......
...@@ -661,7 +661,7 @@ def main(): ...@@ -661,7 +661,7 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
import pdb import pdb
from tools import localpaths # noqa: flake8 from tools import localpaths # noqa: F401
try: try:
main() main()
except Exception: except Exception:
......
...@@ -4,7 +4,7 @@ import logging ...@@ -4,7 +4,7 @@ import logging
import os import os
import sys import sys
from tools import localpaths # noqa: flake8 from tools import localpaths # noqa: F401
from six import iteritems from six import iteritems
from . import virtualenv from . import virtualenv
......
...@@ -2,7 +2,7 @@ html5lib==1.0.1 ...@@ -2,7 +2,7 @@ html5lib==1.0.1
mozinfo==1.1.0 mozinfo==1.1.0
mozlog==4.2.0 mozlog==4.2.0
mozdebug==0.1.1 mozdebug==0.1.1
pillow==6.0.0 pillow==6.1.0
urllib3[secure]==1.25.3 urllib3[secure]==1.25.3
requests==2.22.0 requests==2.22.0
six==1.12.0 six==1.12.0
...@@ -14,7 +14,7 @@ here = os.path.split(__file__)[0] ...@@ -14,7 +14,7 @@ here = os.path.split(__file__)[0]
repo_root = os.path.abspath(os.path.join(here, os.pardir, os.pardir, os.pardir)) repo_root = os.path.abspath(os.path.join(here, os.pardir, os.pardir, os.pardir))
sys.path.insert(0, repo_root) sys.path.insert(0, repo_root)
from tools import localpaths # noqa: flake8 from tools import localpaths # noqa: F401
from wptserve.handlers import StringHandler from wptserve.handlers import StringHandler
......
...@@ -10,7 +10,7 @@ from .state import SavedState, UnsavedState ...@@ -10,7 +10,7 @@ from .state import SavedState, UnsavedState
def setup_paths(sync_path): def setup_paths(sync_path):
sys.path.insert(0, os.path.abspath(sync_path)) sys.path.insert(0, os.path.abspath(sync_path))
from tools import localpaths # noqa: flake8 from tools import localpaths # noqa: F401
class LoadConfig(Step): class LoadConfig(Step):
"""Step for loading configuration from the ini file and kwargs.""" """Step for loading configuration from the ini file and kwargs."""
......
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