mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
Update web-platform-tests to revision b202bbb5aa0d235b22bac11fe902eab1094ef9d2
This commit is contained in:
parent
9a6c96808b
commit
e90dd8bc6b
43 changed files with 669 additions and 286 deletions
34
tests/wpt/web-platform-tests/.gitignore
vendored
34
tests/wpt/web-platform-tests/.gitignore
vendored
|
@ -1,20 +1,30 @@
|
|||
*#
|
||||
# Python
|
||||
*.py[co]
|
||||
.virtualenv/
|
||||
_venv/
|
||||
.cache/
|
||||
.pytest_cache/
|
||||
|
||||
# Node
|
||||
node_modules/
|
||||
|
||||
# WPT repo stuff
|
||||
/MANIFEST.json
|
||||
|
||||
testharness_runner.html
|
||||
!/testharness_runner.html
|
||||
!/tools/wptrunner/wptrunner/testharness_runner.html
|
||||
|
||||
_certs
|
||||
config.json
|
||||
|
||||
# Various OS/editor specific files
|
||||
*#
|
||||
*.sw[po]
|
||||
*~
|
||||
MANIFEST.json
|
||||
!content-security-policy/support/manifest.json
|
||||
!payment-handler/manifest.json
|
||||
\#*
|
||||
_certs
|
||||
.virtualenv
|
||||
config.json
|
||||
node_modules
|
||||
scratch
|
||||
testharness_runner.html
|
||||
webdriver/.idea
|
||||
.idea/
|
||||
.vscode/
|
||||
.DS_Store
|
||||
*.rej
|
||||
_venv
|
||||
webdriver/.cache
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<html>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// If the response for the HTML file contains "Accept-CH: device-memory" in
|
||||
// the response headers, then the browser should attach device-memory client
|
||||
// hint in the HTTP request headers. Test this functionality by fetching an
|
||||
// XHR from this page. The response headers for this page include
|
||||
// "Accept-CH: device-memory".
|
||||
//
|
||||
// echo_device_memory_header_received.py includes "device-memory-received" in
|
||||
// the response headers only if the request included "device-memory" in the
|
||||
// headers.
|
||||
|
||||
promise_test(t => {
|
||||
return fetch("/client-hints/echo_device_memory_header_received.py").then(r => {
|
||||
assert_equals(r.status, 200)
|
||||
// Verify that the browser included "device-memory" in the headers when
|
||||
// fetching the XHR.
|
||||
assert_true(r.headers.has("device-memory-received"));
|
||||
});
|
||||
}, "Accept-CH header test");
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1 @@
|
|||
Accept-CH: device-memory
|
|
@ -0,0 +1,8 @@
|
|||
def main(request, response):
|
||||
"""
|
||||
Simple handler that sets a response header based on if device-memory
|
||||
request header was received or not.
|
||||
"""
|
||||
|
||||
if "device-memory" in request.headers:
|
||||
response.headers.set("device-memory-received", "true")
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Child of block with clear</title>
|
||||
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
|
||||
<link rel="help" href="https://www.w3.org/TR/CSS22/visuren.html#flow-control" title="9.5.2 Controlling flow next to floats: the 'clear' property">
|
||||
<link rel="match" href="../../reference/ref-filled-green-100px-square-only.html">
|
||||
<p>Test passes if there is a filled green square.</p>
|
||||
<div style="position:relative; top:-20px;">
|
||||
<div style="float:left; margin-top:20px; width:50px; height:50px; background:green;"></div>
|
||||
<div style="padding-top:1px;">
|
||||
<div style="margin-top:19px; width:100px; background:green;">
|
||||
<div style="clear:left; margin-top:25px; width:100px; height:50px; background:green;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Child of block with clear</title>
|
||||
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
|
||||
<link rel="help" href="https://www.w3.org/TR/CSS22/visuren.html#flow-control" title="9.5.2 Controlling flow next to floats: the 'clear' property">
|
||||
<link rel="match" href="../../reference/ref-filled-green-200px-square.html">
|
||||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
|
||||
<div id="container" style="overflow:hidden; width:200px; height:200px; background:red;">
|
||||
<div style="float:left; width:10px; height:50px;"></div>
|
||||
<div style="float:right; width:10px; height:100px;"></div>
|
||||
<div style="clear:right;">
|
||||
<div style="clear:left; height:200px; background:green;"></div>
|
||||
</div>
|
||||
<div style="height:10000px;"></div>
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById("container").scrollTop = 100;
|
||||
</script>
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Child of block with clear</title>
|
||||
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
|
||||
<link rel="help" href="https://www.w3.org/TR/CSS22/visuren.html#flow-control" title="9.5.2 Controlling flow next to floats: the 'clear' property">
|
||||
<link rel="match" href="../../reference/ref-filled-green-100px-square-only.html">
|
||||
<p>Test passes if there is a filled green square.</p>
|
||||
<div style="position:relative; z-index:-1; top:-50px; width:100px; background:green;">
|
||||
<div style="float:left; width:100px; height:50px; background:white;"></div>
|
||||
<div style="clear:left; margin-top:25px;">
|
||||
<div style="height:50px; margin-top:150px; background:white;"></div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Child of block with clear</title>
|
||||
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
|
||||
<link rel="help" href="https://www.w3.org/TR/CSS22/visuren.html#flow-control" title="9.5.2 Controlling flow next to floats: the 'clear' property">
|
||||
<link rel="match" href="../../reference/ref-filled-green-200px-square.html">
|
||||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
|
||||
<div style="width:200px; height:200px; background:red;">
|
||||
<div style="float:left; width:200px; height:100px; background:green;"></div>
|
||||
<div style="clear:left; margin-top:100px;">
|
||||
<div style="height:100px; margin-top:-1000px; background:green;"></div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Child of block with clear</title>
|
||||
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
|
||||
<link rel="help" href="https://www.w3.org/TR/CSS22/visuren.html#flow-control" title="9.5.2 Controlling flow next to floats: the 'clear' property">
|
||||
<link rel="match" href="../../reference/ref-filled-green-200px-square.html">
|
||||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
|
||||
<div style="width:200px; height:200px; background:red;">
|
||||
<div style="float:left; width:200px; height:100px; background:green;"></div>
|
||||
<div style="clear:left;">
|
||||
<div style="height:100px; background:green;"></div>
|
||||
</div>
|
||||
</div>
|
|
@ -9,8 +9,8 @@
|
|||
'use strict';
|
||||
|
||||
const gInvalidTestUnits = [
|
||||
{ value: '', desc: 'an empty string' },
|
||||
{ value: 'lemon', desc: 'an invalid unit' },
|
||||
{ unit: '', desc: 'an empty string' },
|
||||
{ unit: 'lemon', desc: 'an invalid unit' },
|
||||
];
|
||||
|
||||
for (const {unit, desc} of gInvalidTestUnits) {
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>scroll-padding related properties</title>
|
||||
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-get">
|
||||
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-set">
|
||||
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#property-stle-value-normalization">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../resources/testhelper.js"></script>
|
||||
<script src="resources/testsuite.js"></script>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
for (const suffix of ['top', 'left', 'right', 'bottom']) {
|
||||
runPropertyTests('scroll-padding-' + suffix, [
|
||||
{ syntax: '<percentage>' },
|
||||
{ syntax: '<length>' },
|
||||
]);
|
||||
}
|
||||
|
||||
for (const suffix of ['inline-start', 'block-start', 'inline-end', 'block-end']) {
|
||||
runPropertyTests('scroll-padding-' + suffix, [
|
||||
{ syntax: '<percentage>' },
|
||||
{ syntax: '<length>' },
|
||||
]);
|
||||
}
|
||||
|
||||
runUnsupportedPropertyTests('scroll-padding',
|
||||
['0%', '1px 2px', '3% 4px 5%', '6px 7% 8% 9px']
|
||||
);
|
||||
|
||||
</script>
|
|
@ -16,15 +16,14 @@
|
|||
<script type="text/javascript">
|
||||
test(function() {
|
||||
var test = document.getElementById("test");
|
||||
assert_own_property(test, "style");
|
||||
assert_readonly(test, "style");
|
||||
assert_idl_attribute(test, "style");
|
||||
declaration = test.style;
|
||||
}, "CSSStyleDeclaration_accessible", {
|
||||
assert: "Can access CSSStyleDeclaration through style property"
|
||||
});
|
||||
|
||||
test(function() {
|
||||
assert_regexp_match(declaration.cssText, /margin-left: 5px;\s*/);
|
||||
assert_equals(declaration.cssText, "margin-left: 5px;");
|
||||
assert_equals(declaration.getPropertyValue("margin-left"), "5px");
|
||||
}, "read", {
|
||||
assert: "initial property values are correct"
|
||||
|
@ -32,7 +31,7 @@
|
|||
|
||||
test(function() {
|
||||
declaration.cssText = "margin-left: 10px; padding-left: 10px;";
|
||||
assert_regexp_match(declaration.cssText, /margin-left: 10px;\s+padding-left: 10px;\s+/);
|
||||
assert_equals(declaration.cssText, "margin-left: 10px; padding-left: 10px;");
|
||||
assert_equals(declaration.length, 2);
|
||||
assert_equals(declaration.item(0), "margin-left");
|
||||
assert_equals(declaration.item(1), "padding-left");
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
assert_equals(mediaList.mediaText, "all, screen");
|
||||
|
||||
}, "mediatest_medialist_serialize_comma",
|
||||
{ help: ["http://www.w3.org/TR/cssom-1/#the-medialist-interface", "http://www.w3.org/TR/cssom-1/#serializing-media-queries"],
|
||||
{ help: ["http://www.w3.org/TR/cssom-1/#the-medialist-interface", "http://www.w3.org/TR/cssom-1/#serialize-a-media-query-list"],
|
||||
assert: ["To serialize a comma-separated list concatenate all items of the list in list order while separating them by \",\" (U+002C), followed by a space (U+0020)."] });
|
||||
|
||||
test(function() {
|
||||
|
@ -75,11 +75,11 @@
|
|||
|
||||
mediaList.appendMedium('screen');
|
||||
mediaList.appendMedium('print');
|
||||
assert_equals(mediaList.mediaText, "all, print, screen");
|
||||
assert_equals(mediaList.mediaText, "all, screen, print");
|
||||
|
||||
}, "mediatest_medialist_serialize_lexicographical",
|
||||
{ help: ["http://www.w3.org/TR/cssom-1/#the-medialist-interface", "http://www.w3.org/TR/cssom-1/#serializing-media-queries"],
|
||||
assert: ["Each media query in the list of media queries should be sorted in lexicographical order."] });
|
||||
}, "mediatest_medialist_serialize_order",
|
||||
{ help: ["http://www.w3.org/TR/cssom-1/#the-medialist-interface", "http://www.w3.org/TR/cssom-1/#serialize-a-media-query-list"],
|
||||
assert: ["Each media query should be sorted in the same order as they appear in the list of media queries."] });
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
|
||||
media_list.appendMedium("all");
|
||||
|
||||
media_list.deleteMedium("screen");
|
||||
assert_throws("NotFoundError", () => media_list.deleteMedium("screen"));
|
||||
|
||||
assert_equals(media_list.length, 1);
|
||||
assert_equals(media_list.item(0), "all");
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
assert_equals(media_list.length, 2);
|
||||
assert_equals(media_list.item(0), "screen");
|
||||
assert_equals(media_list.item(1), "all");
|
||||
assert_equals(media_list.mediaText, "all, screen");
|
||||
assert_equals(media_list.mediaText, "screen, all");
|
||||
}, "appendMedium_correctly_appends_medium_to_nonempty_MediaList",
|
||||
{ assert: "MediaList.appendMedium correctly adds medium to a MediaList that already has a medium." });
|
||||
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
var styleSheet;
|
||||
var linkSheet;
|
||||
test(function() {
|
||||
assert_own_property(styleElement, "sheet");
|
||||
assert_idl_attribute(styleElement, "sheet");
|
||||
assert_readonly(styleElement, "sheet");
|
||||
styleSheet = styleElement.sheet;
|
||||
assert_true(styleSheet instanceof CSSStyleSheet);
|
||||
assert_own_property(linkElement, "sheet");
|
||||
assert_idl_attribute(linkElement, "sheet");
|
||||
linkSheet = linkElement.sheet;
|
||||
assert_true(linkSheet instanceof CSSStyleSheet);
|
||||
}, "sheet_property",
|
||||
|
@ -48,8 +48,8 @@
|
|||
assert: "The sheet property on LinkStyle should always return the current associated style sheet." });
|
||||
|
||||
test(function() {
|
||||
assert_own_property(styleSheet, "ownerRule");
|
||||
assert_own_property(styleSheet, "cssRules");
|
||||
assert_idl_attribute(styleSheet, "ownerRule");
|
||||
assert_idl_attribute(styleSheet, "cssRules");
|
||||
assert_inherits(styleSheet, "insertRule");
|
||||
assert_inherits(styleSheet, "deleteRule");
|
||||
|
||||
|
@ -71,13 +71,13 @@
|
|||
assert: "CSSStyleSheet initial property values are correct" });
|
||||
|
||||
test(function() {
|
||||
assert_own_property(styleSheet, "type");
|
||||
assert_own_property(styleSheet, "disabled");
|
||||
assert_own_property(styleSheet, "ownerNode");
|
||||
assert_own_property(styleSheet, "parentStyleSheet");
|
||||
assert_own_property(styleSheet, "href");
|
||||
assert_own_property(styleSheet, "title");
|
||||
assert_own_property(styleSheet, "media");
|
||||
assert_idl_attribute(styleSheet, "type");
|
||||
assert_idl_attribute(styleSheet, "disabled");
|
||||
assert_idl_attribute(styleSheet, "ownerNode");
|
||||
assert_idl_attribute(styleSheet, "parentStyleSheet");
|
||||
assert_idl_attribute(styleSheet, "href");
|
||||
assert_idl_attribute(styleSheet, "title");
|
||||
assert_idl_attribute(styleSheet, "media");
|
||||
|
||||
assert_readonly(styleSheet, "type");
|
||||
assert_readonly(styleSheet, "ownerNode");
|
||||
|
|
|
@ -11,56 +11,15 @@
|
|||
<h1>idlharness test</h1>
|
||||
<p>This test validates the WebIDL included in the Encoding Living Standard.</p>
|
||||
|
||||
<script type="text/plain" class="untested-idl">
|
||||
interface Window {};
|
||||
</script>
|
||||
|
||||
<script type="text/plain" class="idl">
|
||||
// 8.1 Interface TextDecoder
|
||||
|
||||
dictionary TextDecoderOptions {
|
||||
boolean fatal = false;
|
||||
boolean ignoreBOM = false;
|
||||
};
|
||||
|
||||
dictionary TextDecodeOptions {
|
||||
boolean stream = false;
|
||||
};
|
||||
|
||||
[Constructor(optional DOMString label = "utf-8", optional TextDecoderOptions options),
|
||||
Exposed=(Window,Worker)]
|
||||
interface TextDecoder {
|
||||
readonly attribute DOMString encoding;
|
||||
readonly attribute boolean fatal;
|
||||
readonly attribute boolean ignoreBOM;
|
||||
USVString decode(optional BufferSource input, optional TextDecodeOptions options);
|
||||
};
|
||||
|
||||
// 8.2 Interface TextDecoder
|
||||
|
||||
[Constructor,
|
||||
Exposed=(Window,Worker)]
|
||||
interface TextEncoder {
|
||||
readonly attribute DOMString encoding;
|
||||
[NewObject] Uint8Array encode(optional USVString input = "");
|
||||
};
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function select(selector) {
|
||||
return [].slice.call(document.querySelectorAll(selector))
|
||||
.map(function(e) { return e.textContent; })
|
||||
.join('\n\n');
|
||||
}
|
||||
|
||||
var idl = select('.idl')
|
||||
var untested = select('.untested-idl');
|
||||
var idl_array = new IdlArray();
|
||||
idl_array.add_untested_idls(untested);
|
||||
idl_array.add_idls(idl);
|
||||
idl_array.add_objects({
|
||||
TextEncoder: ['new TextEncoder()'],
|
||||
TextDecoder: ['new TextDecoder()']
|
||||
});
|
||||
idl_array.test();
|
||||
promise_test(async() => {
|
||||
const text = await (await fetch('/interfaces/encoding.idl')).text();
|
||||
const idl_array = new IdlArray();
|
||||
idl_array.add_idls(text);
|
||||
idl_array.add_objects({
|
||||
TextEncoder: ['new TextEncoder()'],
|
||||
TextDecoder: ['new TextDecoder()']
|
||||
});
|
||||
idl_array.test();
|
||||
}, 'Test driver');
|
||||
</script>
|
||||
|
|
|
@ -32,7 +32,7 @@ function redirectLocation(desc, redirectUrl, redirectLocation, redirectStatus, r
|
|||
|
||||
var redirUrl = RESOURCES_DIR + "redirect.py";
|
||||
var locationUrl = "top.txt";
|
||||
var invalidLocationUrl = "#invalidurl:";
|
||||
var invalidLocationUrl = "invalidurl:";
|
||||
var dataLocationUrl = "data:,data%20url";
|
||||
// FIXME: We may want to mix redirect-mode and cors-mode.
|
||||
// FIXME: Add tests for "error" redirect-mode.
|
||||
|
|
24
tests/wpt/web-platform-tests/interfaces/encoding.idl
Normal file
24
tests/wpt/web-platform-tests/interfaces/encoding.idl
Normal file
|
@ -0,0 +1,24 @@
|
|||
dictionary TextDecoderOptions {
|
||||
boolean fatal = false;
|
||||
boolean ignoreBOM = false;
|
||||
};
|
||||
|
||||
dictionary TextDecodeOptions {
|
||||
boolean stream = false;
|
||||
};
|
||||
|
||||
[Constructor(optional DOMString label = "utf-8", optional TextDecoderOptions options),
|
||||
Exposed=(Window,Worker)]
|
||||
interface TextDecoder {
|
||||
readonly attribute DOMString encoding;
|
||||
readonly attribute boolean fatal;
|
||||
readonly attribute boolean ignoreBOM;
|
||||
USVString decode(optional BufferSource input, optional TextDecodeOptions options);
|
||||
};
|
||||
|
||||
[Constructor,
|
||||
Exposed=(Window,Worker)]
|
||||
interface TextEncoder {
|
||||
readonly attribute DOMString encoding;
|
||||
[NewObject] Uint8Array encode(optional USVString input = "");
|
||||
};
|
|
@ -6,10 +6,10 @@ interface Magnetometer : Sensor {
|
|||
readonly attribute double? z;
|
||||
};
|
||||
|
||||
enum LocalCoordinateSystem { "device", "screen" };
|
||||
enum MagnetometerLocalCoordinateSystem { "device", "screen" };
|
||||
|
||||
dictionary MagnetometerSensorOptions : SensorOptions {
|
||||
LocalCoordinateSystem referenceFrame = "device";
|
||||
MagnetometerLocalCoordinateSystem referenceFrame = "device";
|
||||
};
|
||||
|
||||
[Constructor(optional MagnetometerSensorOptions sensorOptions), SecureContext,
|
||||
|
|
|
@ -6,10 +6,10 @@ interface OrientationSensor : Sensor {
|
|||
void populateMatrix(RotationMatrixType targetMatrix);
|
||||
};
|
||||
|
||||
enum LocalCoordinateSystem { "device", "screen" };
|
||||
enum OrientationSensorLocalCoordinateSystem { "device", "screen" };
|
||||
|
||||
dictionary OrientationSensorOptions : SensorOptions {
|
||||
LocalCoordinateSystem referenceFrame = "device";
|
||||
OrientationSensorLocalCoordinateSystem referenceFrame = "device";
|
||||
};
|
||||
|
||||
[Constructor(optional OrientationSensorOptions sensorOptions), SecureContext, Exposed=Window]
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for PaymentRequest.abort() method</title>
|
||||
<link rel="help" href="https://w3c.github.io/browser-payment-api/#abort-method">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
"use strict";
|
||||
setup({
|
||||
// Ignore unhandled rejections resulting from .show()'s acceptPromise
|
||||
// not being explicitly handled.
|
||||
allow_uncaught_exception: true,
|
||||
explicit_done: true,
|
||||
explicit_timeout: true,
|
||||
});
|
||||
const basicCard = Object.freeze({ supportedMethods: "basic-card" });
|
||||
const defaultMethods = Object.freeze([basicCard]);
|
||||
const defaultDetails = Object.freeze({
|
||||
total: {
|
||||
label: "Total",
|
||||
amount: {
|
||||
currency: "USD",
|
||||
value: "1.00",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
promise_test(async t => {
|
||||
// request is in "created" state
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails);
|
||||
await promise_rejects(t, "InvalidStateError", request.abort());
|
||||
}, `Throws if the promise [[state]] is not "interactive"`);
|
||||
|
||||
function manualTest1(elem){
|
||||
elem.disabled = true;
|
||||
promise_test(async t => {
|
||||
// request is in "created" state.
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails);
|
||||
await promise_rejects(t, "InvalidStateError", request.abort());
|
||||
// Call it again, for good measure.
|
||||
await promise_rejects(t, "InvalidStateError", request.abort());
|
||||
// The request's state is "created", so let's show it
|
||||
// which changes the state to "interactive.".
|
||||
const acceptPromise = request.show();
|
||||
// Let's set request the state to "closed" by calling .abort()
|
||||
try {
|
||||
await request.abort();
|
||||
} catch (err) {
|
||||
assert_unreached("Unexpected promise rejection: " + err.message);
|
||||
}
|
||||
// The request is now "closed", so...
|
||||
await promise_rejects(t, "InvalidStateError", request.abort());
|
||||
await promise_rejects(t, "AbortError", acceptPromise);
|
||||
}, elem.textContent.trim());
|
||||
}
|
||||
|
||||
function manualTest2(elem){
|
||||
elem.disabled = true;
|
||||
promise_test(async t => {
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails);
|
||||
const acceptPromise = request.show();
|
||||
try {
|
||||
await request.abort();
|
||||
} catch (err) {
|
||||
assert_unreached("Unexpected promise rejection: " + err.message);
|
||||
}
|
||||
await promise_rejects(t, "AbortError", acceptPromise);
|
||||
// As request is now "closed", trying to show it will fail
|
||||
await promise_rejects(t, "InvalidStateError", request.show());
|
||||
}, elem.textContent.trim());
|
||||
done();
|
||||
}
|
||||
</script>
|
||||
|
||||
<h2>Test for PaymentRequest.abort() method</h2>
|
||||
<p>
|
||||
Click on each button in sequence from top to bottom without refreshing the page.
|
||||
No payment sheet will be shown, but the tests will run in the background.
|
||||
</p>
|
||||
<ol>
|
||||
<li>
|
||||
<button onclick="manualTest1(this)">
|
||||
Calling abort must not change the [[state]] until after "interactive".
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button onclick="manualTest2(this)">
|
||||
Calling .abort() causes acceptPromise to reject and closes the request.
|
||||
</button>
|
||||
</li>
|
||||
</ol>
|
||||
<small>
|
||||
If you find a buggy test, please <a href="https://github.com/w3c/web-platform-tests/issues">file a bug</a>
|
||||
and tag one of the <a href="https://github.com/w3c/web-platform-tests/blob/master/payment-request/OWNERS">owners</a>.
|
||||
</small>
|
|
@ -1,65 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- Copyright © 2017 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
|
||||
<meta charset="utf-8">
|
||||
<title>Test for PaymentRequest.abort() method</title>
|
||||
<link rel="help" href="https://w3c.github.io/browser-payment-api/#abort-method">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
"use strict";
|
||||
setup(() => {}, {
|
||||
// Ignore unhandled rejections resulting from .show()'s acceptPromise
|
||||
// not being explicitly handled.
|
||||
allow_uncaught_exception: true,
|
||||
});
|
||||
const basicCard = Object.freeze({ supportedMethods: "basic-card" });
|
||||
const defaultMethods = Object.freeze([basicCard]);
|
||||
const defaultDetails = Object.freeze({
|
||||
total: {
|
||||
label: "Total",
|
||||
amount: {
|
||||
currency: "USD",
|
||||
value: "1.00",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
promise_test(async t => {
|
||||
// request is in "created" state
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails);
|
||||
await promise_rejects(t, "InvalidStateError", request.abort());
|
||||
}, `Throws if the promise [[state]] is not "interactive"`);
|
||||
|
||||
promise_test(async t => {
|
||||
// request is in "created" state.
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails);
|
||||
await promise_rejects(t, "InvalidStateError", request.abort());
|
||||
// Call it again, for good measure.
|
||||
await promise_rejects(t, "InvalidStateError", request.abort());
|
||||
// The request's state is "created", so let's show it
|
||||
// which changes the state to "interactive.".
|
||||
request.show();
|
||||
// Let's set request the state to "closed" by calling .abort()
|
||||
try {
|
||||
await request.abort();
|
||||
} catch (err) {
|
||||
assert_unreached("Unexpected promise rejection: " + err.message);
|
||||
}
|
||||
// The request is now "closed", so...
|
||||
await promise_rejects(t, "InvalidStateError", request.abort());
|
||||
}, `Calling abort must not change the [[state]] until after "interactive"`);
|
||||
|
||||
promise_test(async t => {
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails);
|
||||
const acceptPromise = request.show();
|
||||
try {
|
||||
await request.abort();
|
||||
} catch (err) {
|
||||
assert_unreached("Unexpected promise rejection: " + err.message);
|
||||
}
|
||||
await promise_rejects(t, "AbortError", acceptPromise);
|
||||
// As request is now "closed", trying to show it will fail
|
||||
await promise_rejects(t, "InvalidStateError", request.show());
|
||||
}, "calling .abort() causes acceptPromise to reject and closes the request.");
|
||||
|
||||
</script>
|
|
@ -1,11 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- Copyright © 2017 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
|
||||
<meta charset="utf-8">
|
||||
<title>Tests for PaymentRequest.canMakePayment() method</title>
|
||||
<link rel="help" href="https://w3c.github.io/browser-payment-api/#show-method">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({
|
||||
explicit_done: true,
|
||||
explicit_timeout: true,
|
||||
});
|
||||
|
||||
const basicCard = Object.freeze({ supportedMethods: "basic-card" });
|
||||
const defaultMethods = Object.freeze([basicCard]);
|
||||
const defaultDetails = Object.freeze({
|
||||
|
@ -38,47 +42,6 @@ promise_test(async t => {
|
|||
}
|
||||
}, `If request.[[state]] is "created", then return a promise that resolves to true for known method.`);
|
||||
|
||||
promise_test(async t => {
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails);
|
||||
const acceptPromise = request.show(); // Sets state to "interactive"
|
||||
const canMakePaymentPromise = request.canMakePayment();
|
||||
try {
|
||||
const result = await canMakePaymentPromise;
|
||||
assert_true(
|
||||
false,
|
||||
`canMakePaymentPromise should have thrown InvalidStateError`
|
||||
);
|
||||
} catch (err) {
|
||||
await promise_rejects(t, "InvalidStateError", canMakePaymentPromise);
|
||||
} finally {
|
||||
await request.abort();
|
||||
await promise_rejects(t, "AbortError", acceptPromise);
|
||||
}
|
||||
// The state should be "closed"
|
||||
await promise_rejects(t, "InvalidStateError", request.canMakePayment());
|
||||
}, `If request.[[state]] is "interactive", then return a promise rejected with an "InvalidStateError" DOMException.`);
|
||||
|
||||
promise_test(async t => {
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails);
|
||||
const acceptPromise = request.show(); // The state is now "interactive"
|
||||
acceptPromise.catch(() => {}); // no-op, just to silence unhandled rejection in devtools.
|
||||
await request.abort(); // The state is now "closed"
|
||||
await promise_rejects(t, "InvalidStateError", request.canMakePayment());
|
||||
try {
|
||||
const result = await request.canMakePayment();
|
||||
assert_true(
|
||||
false,
|
||||
`should have thrown InvalidStateError, but instead returned "${result}"`
|
||||
);
|
||||
} catch (err) {
|
||||
assert_equals(
|
||||
err.name,
|
||||
"InvalidStateError",
|
||||
"must be an InvalidStateError."
|
||||
);
|
||||
}
|
||||
}, `If request.[[state]] is "closed", then return a promise rejected with an "InvalidStateError" DOMException.`);
|
||||
|
||||
promise_test(async t => {
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails);
|
||||
assert_true(await request.canMakePayment(), "basic-card should be supported");
|
||||
|
@ -160,4 +123,74 @@ promise_test(async t => {
|
|||
}
|
||||
}
|
||||
}, `Optionally, at the user agent's discretion, return a promise rejected with a "NotAllowedError" DOMException.`);
|
||||
|
||||
function manualTest1(elem){
|
||||
elem.disabled = true;
|
||||
promise_test(async t => {
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails);
|
||||
const acceptPromise = request.show(); // Sets state to "interactive"
|
||||
const canMakePaymentPromise = request.canMakePayment();
|
||||
try {
|
||||
const result = await canMakePaymentPromise;
|
||||
assert_true(
|
||||
false,
|
||||
`canMakePaymentPromise should have thrown InvalidStateError`
|
||||
);
|
||||
} catch (err) {
|
||||
await promise_rejects(t, "InvalidStateError", canMakePaymentPromise);
|
||||
} finally {
|
||||
await request.abort();
|
||||
await promise_rejects(t, "AbortError", acceptPromise);
|
||||
}
|
||||
// The state should be "closed"
|
||||
await promise_rejects(t, "InvalidStateError", request.canMakePayment());
|
||||
}, elem.textContent.trim());
|
||||
}
|
||||
|
||||
function manualTest2(elem){
|
||||
elem.disabled = true;
|
||||
promise_test(async t => {
|
||||
const request = new PaymentRequest(defaultMethods, defaultDetails);
|
||||
const acceptPromise = request.show(); // The state is now "interactive"
|
||||
acceptPromise.catch(() => {}); // no-op, just to silence unhandled rejection in devtools.
|
||||
await request.abort(); // The state is now "closed"
|
||||
await promise_rejects(t, "InvalidStateError", request.canMakePayment());
|
||||
try {
|
||||
const result = await request.canMakePayment();
|
||||
assert_true(
|
||||
false,
|
||||
`should have thrown InvalidStateError, but instead returned "${result}"`
|
||||
);
|
||||
} catch (err) {
|
||||
assert_equals(
|
||||
err.name,
|
||||
"InvalidStateError",
|
||||
"must be an InvalidStateError."
|
||||
);
|
||||
}
|
||||
}, elem.textContent.trim());
|
||||
done();
|
||||
}
|
||||
</script>
|
||||
|
||||
<h2>Tests for PaymentRequest.canMakePayment() method</h2>
|
||||
<p>
|
||||
Click on each button in sequence from top to bottom without refreshing the page.
|
||||
No payment sheet will be shown, but the tests will run in the background.
|
||||
</p>
|
||||
<ol>
|
||||
<li>
|
||||
<button onclick="manualTest1(this)">
|
||||
If request.[[state]] is "interactive", then return a promise rejected with an "InvalidStateError" DOMException.
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button onclick="manualTest2(this)">
|
||||
If request.[[state]] is "closed", then return a promise rejected with an "InvalidStateError" DOMException.
|
||||
</button>
|
||||
</li>
|
||||
</ol>
|
||||
<small>
|
||||
If you find a buggy test, please <a href="https://github.com/w3c/web-platform-tests/issues">file a bug</a>
|
||||
and tag one of the <a href="https://github.com/w3c/web-platform-tests/blob/master/payment-request/OWNERS">owners</a>.
|
||||
</small>
|
6
tests/wpt/web-platform-tests/testharness_runner.html
Normal file
6
tests/wpt/web-platform-tests/testharness_runner.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
<!doctype html>
|
||||
<title></title>
|
||||
<script>
|
||||
var timeout_multiplier = 1;
|
||||
var win = null;
|
||||
</script>
|
26
tests/wpt/web-platform-tests/tools/.coveragerc
Normal file
26
tests/wpt/web-platform-tests/tools/.coveragerc
Normal file
|
@ -0,0 +1,26 @@
|
|||
[run]
|
||||
branch = True
|
||||
parallel = True
|
||||
omit =
|
||||
html5lib/*
|
||||
py/*
|
||||
pytest/*
|
||||
pywebsocket/*
|
||||
six/*
|
||||
webdriver/*
|
||||
wptserve/*
|
||||
*/site-packages/*
|
||||
*/lib_pypy/*
|
||||
|
||||
[paths]
|
||||
html5lib =
|
||||
html5lib/html5lib
|
||||
.tox/**/site-packages/html5lib
|
||||
|
||||
pytest =
|
||||
pytest/_pytest
|
||||
.tox/**/site-packages/_pytest
|
||||
|
||||
py =
|
||||
py/py
|
||||
.tox/**/site-packages/py
|
|
@ -1,5 +1,6 @@
|
|||
*#
|
||||
.coverage*
|
||||
.coverage
|
||||
.coverage.*
|
||||
htmlcov/
|
||||
coverage.xml
|
||||
.tox/
|
||||
|
|
|
@ -9,7 +9,6 @@ import os
|
|||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
|
@ -135,28 +134,6 @@ def check_ahem_copy(repo_root, path):
|
|||
return []
|
||||
|
||||
|
||||
def check_git_ignore(repo_root, paths):
|
||||
errors = []
|
||||
with tempfile.TemporaryFile('w+') as f:
|
||||
f.write('\n'.join(paths))
|
||||
f.seek(0)
|
||||
try:
|
||||
matches = subprocess.check_output(
|
||||
["git", "check-ignore", "--verbose", "--no-index", "--stdin"], stdin=f)
|
||||
for match in matches.strip().split('\n'):
|
||||
match_filter, path = match.split()
|
||||
_, _, filter_string = match_filter.split(':')
|
||||
# If the matching filter reported by check-ignore is a special-case exception,
|
||||
# that's fine. Otherwise, it requires a new special-case exception.
|
||||
if filter_string != '!' + path:
|
||||
errors += [("IGNORED PATH", "%s matches an ignore filter in .gitignore - "
|
||||
"please add a .gitignore exception" % path, path, None)]
|
||||
except subprocess.CalledProcessError as e:
|
||||
# Nonzero return code means that no match exists.
|
||||
pass
|
||||
return errors
|
||||
|
||||
|
||||
drafts_csswg_re = re.compile(r"https?\:\/\/drafts\.csswg\.org\/([^/?#]+)")
|
||||
w3c_tr_re = re.compile(r"https?\:\/\/www\.w3c?\.org\/TR\/([^/?#]+)")
|
||||
w3c_dev_re = re.compile(r"https?\:\/\/dev\.w3c?\.org\/[^/?#]+\/([^/?#]+)")
|
||||
|
@ -301,9 +278,7 @@ def filter_whitelist_errors(data, errors):
|
|||
|
||||
for i, (error_type, msg, path, line) in enumerate(errors):
|
||||
normpath = os.path.normcase(path)
|
||||
# Allow whitelisting all lint errors except the IGNORED PATH lint,
|
||||
# which explains how to fix it correctly and shouldn't be ignored.
|
||||
if error_type in data and error_type != "IGNORED PATH":
|
||||
if error_type in data:
|
||||
wl_files = data[error_type]
|
||||
for file_match, allowed_lines in iteritems(wl_files):
|
||||
if None in allowed_lines or line in allowed_lines:
|
||||
|
@ -865,13 +840,6 @@ path_lints = [check_path_length, check_worker_collision, check_ahem_copy]
|
|||
all_paths_lints = [check_css_globally_unique]
|
||||
file_lints = [check_regexp_line, check_parsed, check_python_ast, check_script_metadata]
|
||||
|
||||
# Don't break users of the lint that don't have git installed.
|
||||
try:
|
||||
subprocess.check_output(["git", "--version"])
|
||||
all_paths_lints += [check_git_ignore]
|
||||
except subprocess.CalledProcessError:
|
||||
print('No git present; skipping .gitignore lint.')
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = create_parser().parse_args()
|
||||
error_count = main(**vars(args))
|
||||
|
|
6
tests/wpt/web-platform-tests/tools/third_party/funcsigs/.coveragerc
vendored
Normal file
6
tests/wpt/web-platform-tests/tools/third_party/funcsigs/.coveragerc
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
[run]
|
||||
source=funcsigs
|
||||
omit=funcsigs/odict*
|
||||
|
||||
[report]
|
||||
include=funcsigs*
|
4
tests/wpt/web-platform-tests/tools/third_party/pytest/.coveragerc
vendored
Normal file
4
tests/wpt/web-platform-tests/tools/third_party/pytest/.coveragerc
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
[run]
|
||||
omit =
|
||||
# standlonetemplate is read dynamically and tested by test_genscript
|
||||
*standalonetemplate.py
|
11
tests/wpt/web-platform-tests/tools/wptserve/.coveragerc
Normal file
11
tests/wpt/web-platform-tests/tools/wptserve/.coveragerc
Normal file
|
@ -0,0 +1,11 @@
|
|||
[run]
|
||||
branch = True
|
||||
parallel = True
|
||||
omit =
|
||||
*/site-packages/*
|
||||
*/lib_pypy/*
|
||||
|
||||
[paths]
|
||||
wptserve =
|
||||
wptserve
|
||||
.tox/**/site-packages/wptserve
|
|
@ -11,6 +11,39 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
test(t => {
|
||||
const anim = new Animation();
|
||||
assert_equals(anim.playState, 'idle');
|
||||
assert_equals(anim.currentTime, null);
|
||||
|
||||
// This should not throw because the currentTime is already null.
|
||||
anim.currentTime = null;
|
||||
}, 'Setting the current time of a pending animation to unresolved does not'
|
||||
+ ' throw a TypeError');
|
||||
|
||||
promise_test(async t => {
|
||||
const anim = createDiv(t).animate(null, 100 * MS_PER_SEC);
|
||||
await anim.ready;
|
||||
|
||||
assert_greater_than_equal(anim.currentTime, 0);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
anim.currentTime = null;
|
||||
});
|
||||
}, 'Setting the current time of a playing animation to unresolved throws a'
|
||||
+ ' TypeError');
|
||||
|
||||
promise_test(async t => {
|
||||
const anim = createDiv(t).animate(null, 100 * MS_PER_SEC);
|
||||
await anim.ready;
|
||||
anim.pause();
|
||||
|
||||
assert_greater_than_equal(anim.currentTime, 0);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
anim.currentTime = null;
|
||||
});
|
||||
}, 'Setting the current time of a paused animation to unresolved throws a'
|
||||
+ ' TypeError');
|
||||
|
||||
promise_test(async t => {
|
||||
const anim = createDiv(t).animate(null, 100 * MS_PER_SEC);
|
||||
await anim.ready;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue