Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255

This commit is contained in:
James Graham 2015-03-27 09:15:38 +00:00
parent b2a5225831
commit 1a81b18b9f
12321 changed files with 544385 additions and 6 deletions

View file

@ -0,0 +1,21 @@
body {
font-size: small;
font-family: sans-serif;
}
p {
line-height: 0;
}
p:first-child {
display: inline;
}
h1 {
display: inline;
}
iframe, object {
border: 1px black solid;
margin: 2px;
}

View file

@ -0,0 +1,31 @@
body {
font-size: small;
font-family: sans-serif;
}
a {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
h3 {
display: inline;
font-size: medium;
}
h3 + p {
display: inline;
margin-left: 0.5em;
}
li {
list-style-type: none;
}
ul {
padding-left: 2em;
margin-left: 0;
}

View file

@ -0,0 +1,50 @@
.testrefs {
font-size: small;
margin-left: 0.2em;
margin-right: 0.2em;
border-bottom: none !important;
font-weight: normal;
font-style: normal;
white-space: normal;
font-family: sans-serif;
}
.kw-must, .kw-required {
background: #fda;
}
.kw-should {
background: #ffa;
}
.kw-none {
background: #dfa;
}
pre.idl .testrefs :link {
color: #00c;
}
pre.idl .testrefs :visited {
color: #609;
}
.testrefs a:hover {
background: transparent;
text-decoration: none;
}
.testrefs:before {
content: '[';
}
.testrefs:after {
content: ']';
}
.testrefs a:first-child {
font-weight: bold;
text-decoration: none;
}

View file

@ -0,0 +1,134 @@
html.fail {
background: #f66;
}
html.pass {
background: #6f6;
}
html.needs_check {
background: #99f;
}
body {
font-size: small;
font-family: sans-serif;
color: black;
}
a:link {
color: #00c;
}
a:visited {
color: #808;
}
body.framed {
font-size: x-small;
}
h1 {
font-size: larger;
margin: 0;
padding-left: 0.5em;
text-indent: -0.5em;
}
p {
margin: 0;
}
p.notes {
margin-bottom: 0.5em;
font-style: italic;
}
ul {
margin: 0;
margin-bottom: 0.5em;
padding: 0;
padding-left: 1em;
}
.refs {
font-style: italic;
margin-bottom: 0.5em;
}
.refs ul {
display: inline;
margin: 0;
padding: 0;
}
.refs li {
display: inline;
list-style-type: none;
margin: 0;
padding: 0;
}
canvas {
display: none;
visibility: hidden;
border: 2px #f0f solid;
background: url(../images/background.png);
}
img.expected {
display: none;
border: 2px #f0f solid;
background: url(../images/background.png);
}
iframe {
border: 2px #f0f solid;
}
.output {
display: none;
}
.show_output .output, .needs_check .output {
display: block !important;
visibility: visible !important;
}
.show_output #show_output {
display: none;
}
.resource {
visibility: hidden;
height: 0;
}
.fallback {
font-size: 2em;
font-weight: bold;
color: #a00;
}
html.minimal body {
color: white;
}
html.fail.minimal {
background: #f00;
}
html.pass.minimal {
background: #080;
}
html.needs_check.minimal {
background: #008;
}
.minimal #d {
display: none !important;
}
.minimal .expectedtext {
visibility: hidden !important;
}
#passtext, #failtext {
display: none;
}
.minimal.pass #passtext, .minimal.fail #failtext {
display: block;
}

View file

@ -0,0 +1,86 @@
function _valToString(val)
{
if (val === undefined || val === null)
return '[' + typeof(val) + ']';
return val.toString() + '[' + typeof(val) + ']';
}
function _assert(cond, text)
{
assert_true(!!cond, text);
}
function _assertSame(a, b, text_a, text_b)
{
var msg = text_a + ' === ' + text_b + ' (got ' + _valToString(a) +
', expected ' + _valToString(b) + ')';
assert_equals(a, b, msg);
}
function _assertDifferent(a, b, text_a, text_b)
{
var msg = text_a + ' !== ' + text_b + ' (got ' + _valToString(a) +
', expected not ' + _valToString(b) + ')';
assert_not_equals(a, b, msg);
}
function _getPixel(canvas, x,y)
{
var ctx = canvas.getContext('2d');
var imgdata = ctx.getImageData(x, y, 1, 1);
return [ imgdata.data[0], imgdata.data[1], imgdata.data[2], imgdata.data[3] ];
}
function _assertPixel(canvas, x,y, r,g,b,a, pos, colour)
{
var c = _getPixel(canvas, x,y);
assert_equals(c[0], r, 'Red channel of the pixel at (' + x + ', ' + y + ')');
assert_equals(c[1], g, 'Green channel of the pixel at (' + x + ', ' + y + ')');
assert_equals(c[2], b, 'Blue channel of the pixel at (' + x + ', ' + y + ')');
assert_equals(c[3], a, 'Alpha channel of the pixel at (' + x + ', ' + y + ')');
}
function _assertPixelApprox(canvas, x,y, r,g,b,a, pos, colour, tolerance)
{
var c = _getPixel(canvas, x,y);
assert_approx_equals(c[0], r, tolerance, 'Red channel of the pixel at (' + x + ', ' + y + ')');
assert_approx_equals(c[1], g, tolerance, 'Green channel of the pixel at (' + x + ', ' + y + ')');
assert_approx_equals(c[2], b, tolerance, 'Blue channel of the pixel at (' + x + ', ' + y + ')');
assert_approx_equals(c[3], a, tolerance, 'Alpha channel of the pixel at (' + x + ', ' + y + ')');
}
function _addTest(testFn)
{
var deferred = false;
window.deferTest = function () { deferred = true; };
on_event(window, "load", function()
{
t.step(function() {
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');
t.step(testFn, window, canvas, ctx);
});
if (!deferred) {
t.done();
}
});
}
function _assertGreen(ctx, canvasWidth, canvasHeight)
{
var testColor = function(d, idx, expected) {
assert_equals(d[idx], expected, "d[" + idx + "]", String(expected));
};
var imagedata = ctx.getImageData(0, 0, canvasWidth, canvasHeight);
var w = imagedata.width, h = imagedata.height, d = imagedata.data;
for (var i = 0; i < h; ++i) {
for (var j = 0; j < w; ++j) {
testColor(d, 4 * (w * i + j) + 0, 0);
testColor(d, 4 * (w * i + j) + 1, 255);
testColor(d, 4 * (w * i + j) + 2, 0);
testColor(d, 4 * (w * i + j) + 3, 255);
}
}
}

View file

@ -0,0 +1 @@
html { color: red; }

View file

@ -0,0 +1,45 @@
def main(request, response):
"""Code for generating large responses where the actual response data
isn't very important.
Two request parameters:
size (required): An integer number of bytes (no suffix) or kilobytes
("kb" suffix) or megabytes ("Mb" suffix).
string (optional): The string to repeat in the response. Defaults to "a".
Example:
/resources/large.py?size=32Mb&string=ab
"""
if not "size" in request.GET:
400, "Need an integer bytes parameter"
bytes_value = request.GET.first("size")
chunk_size = 1024
multipliers = {"kb": 1024,
"Mb": 1024*1024}
suffix = bytes_value[-2:]
if suffix in multipliers:
multiplier = multipliers[suffix]
bytes_value = bytes_value[:-2] * multiplier
try:
num_bytes = int(bytes_value)
except ValueError:
return 400, "Bytes must be an integer possibly with a kb or Mb suffix"
string = str(request.GET.first("string", "a"))
chunk = string * chunk_size
def content():
bytes_sent = 0
while bytes_sent < num_bytes:
if num_bytes - bytes_sent < len(chunk):
yield chunk[num_bytes - bytes_sent]
else:
yield chunk
bytes_sent += len(chunk)
return [("Content-Type", "text/plain")], content()

View file

@ -0,0 +1,35 @@
//
// Returns the URI of a supported video source based on the user agent
//
function getVideoURI(base)
{
var extension = '.mp4';
var videotag = document.createElement("video");
if ( videotag.canPlayType &&
videotag.canPlayType('video/ogg; codecs="theora, vorbis"') )
{
extension = '.ogv';
}
return base + extension;
}
//
// Returns the URI of a supported audio source based on the user agent
//
function getAudioURI(base)
{
var extension = '.mp3';
var audiotag = document.createElement("audio");
if ( audiotag.canPlayType &&
audiotag.canPlayType('audio/ogg') )
{
extension = '.oga';
}
return base + extension;
}

View file

@ -0,0 +1,19 @@
def main(request, response):
"""Simple handler that causes redirection.
The request should typically have two query parameters:
status - The status to use for the redirection. Defaults to 302.
location - The resource to redirect to.
"""
status = 302
if "status" in request.GET:
try:
status = int(request.GET.first("status"))
except ValueError:
pass
response.status = status
location = request.GET.first("location")
response.headers.set("Location", location)

View file

@ -0,0 +1,9 @@
function takeScreenshot() {
document.documentElement.classList.remove("reftest-wait");
}
function takeScreenshotDelayed(timeout) {
setTimeout(function() {
takeScreenshot();
}, timeout);
}

View file

@ -0,0 +1,52 @@
// Tests <http://heycam.github.io/webidl/#es-stringifier>.
function test_stringifier_attribute(aObject, aAttribute, aIsUnforgeable) {
// Step 1.
test(function() {
[null, undefined].forEach(function(v) {
assert_throws(new TypeError(), function() {
aObject.toString.call(v);
});
});
});
// TODO Step 2: security check.
// Step 3.
test(function() {
assert_false("Window" in window && aObject instanceof window.Window);
[{}, window].forEach(function(v) {
assert_throws(new TypeError(), function() {
aObject.toString.call(v)
});
});
});
// Step 4-6.
var expected_value;
test(function() {
expected_value = aObject[aAttribute];
assert_equals(aObject[aAttribute], expected_value,
"The attribute " + aAttribute + " should be pure.");
});
var test_error = { name: "test" };
test(function() {
if (!aIsUnforgeable) {
Object.defineProperty(aObject, aAttribute, {
configurable: true,
get: function() { throw test_error; }
});
}
assert_equals(aObject.toString(), expected_value);
});
test(function() {
if (!aIsUnforgeable) {
Object.defineProperty(aObject, aAttribute, {
configurable: true,
value: { toString: function() { throw test_error; } }
});
}
assert_equals(aObject.toString(), expected_value);
});
}

View file

@ -0,0 +1,4 @@
This is a sample text/plain document.
This is not an HTML document.

View file

@ -0,0 +1,80 @@
function make_absolute_url(options) {
var loc = window.location;
var protocol = get(options, "protocol", loc.protocol);
if (protocol[protocol.length - 1] != ":") {
protocol += ":";
}
var hostname = get(options, "hostname", loc.hostname);
var subdomain = get(options, "subdomain");
if (subdomain) {
hostname = subdomain + "." + hostname;
}
var port = get(options, "port", loc.port)
var path = get(options, "path", loc.pathname);
var query = get(options, "query", loc.search);
var hash = get(options, "hash", loc.hash)
var url = protocol + "//" + hostname;
if (port) {
url += ":" + port;
}
if (path[0] != "/") {
url += "/";
}
url += path;
if (query) {
if (query[0] != "?") {
url += "?";
}
url += query;
}
if (hash) {
if (hash[0] != "#") {
url += "#";
}
url += hash;
}
return url;
}
function get(obj, name, default_val) {
if (obj.hasOwnProperty(name)) {
return obj[name];
}
return default_val;
}
function token() {
var uuid = [to_hex(rand_int(32), 8),
to_hex(rand_int(16), 4),
to_hex(0x4000 | rand_int(12), 4),
to_hex(0x8000 | rand_int(14), 4),
to_hex(rand_int(48), 12)].join("-")
return uuid;
}
function rand_int(bits) {
if (bits < 1 || bits > 53) {
throw new TypeError();
} else {
if (bits >= 1 && bits <= 30) {
return 0 | ((1 << bits) * Math.random());
} else {
var high = (0 | ((1 << (bits - 30)) * Math.random())) * (1 << 30);
var low = 0 | ((1 << 30) * Math.random());
return high + low;
}
}
}
function to_hex(x, length) {
var rv = x.toString(16);
while (rv.length < length) {
rv = "0" + rv;
}
return rv;
}

View file

@ -0,0 +1,115 @@
/* Use this script when you want to test APIs that use vendor prefixes
and define which objects need to be checked for prefixed versions, à la
<script src="vendor-prefix.js"
data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'
data-prefixed-prototypes='[{"ancestors":["HTMLMediaElement"],"name":"srcObject"}]'></script>
data-prefixed-objects lets prefix objects in the global space
data-prefixed-prototypes adds prefixes to interfaces, for objects that
get created during the tests
NB: vendor prefixes are expected to go away in favor of putting
new features behind flag, so hopefully there will be only limited
need to use this
*/
(function () {
var aliases = {};
var documentingPrefixUsage = document.createElement('div');
var vendorPrefixes = ["moz", "ms", "o", "webkit", "Moz", "MS", "O", "WebKit", "op"];
function getParentObject(ancestors) {
var parent = window;
var currentName = "";
ancestors.forEach(function (p) {
currentName = currentName ? currentName + "." + p : p;
if (parent[p] === undefined) {
throw currentName + " is undefined, cannot set prefix alias on child object";
}
parent = parent[p];
});
return parent;
}
function prependPrefix(prefix, name) {
var newName = name[0].toUpperCase() + name.substr(1, name.length);
return prefix + newName;
}
function setPrototypeAlias(obj) {
var parent = getParentObject(obj.ancestors);
if (!parent.prototype.hasOwnProperty(obj.name)) {
vendorPrefixes.forEach(function (prefix) {
if (parent.prototype.hasOwnProperty(prependPrefix(prefix, obj.name))) {
Object.defineProperty(parent.prototype, obj.name,
{get: function() {return this[prependPrefix(prefix, obj.name)];},
set: function(v) {this[prependPrefix(prefix, obj.name)] = v;}
});
aliases[obj.ancestors.join(".") + ".prototype." + obj.name] = obj.ancestors.join(".") + ".prototype." + prependPrefix(prefix, obj.name);
return;
}
});
}
}
function setAlias(obj) {
var parent = getParentObject(obj.ancestors);
if (parent[obj.name] === undefined) {
vendorPrefixes.forEach(function (prefix) {
if (parent[prependPrefix(prefix, obj.name)] !== undefined) {
parent[obj.name] = parent[prependPrefix(prefix, obj.name)];
aliases[obj.ancestors.join(".") + "." + obj.name] = obj.ancestors.join(".") + "." + prependPrefix(prefix, obj.name);
return;
}
});
}
}
if (location.search.indexOf('usePrefixes=1') !== -1) {
if (document.querySelector("script[data-prefixed-objects]")) {
var prefixObjectsData = document.querySelector("script[data-prefixed-objects]").dataset["prefixedObjects"];
try {
var prefixedObjects = JSON.parse(prefixObjectsData);
} catch (e) {
throw "couldn't parse data-prefixed-objects as JSON:" + e;
}
prefixedObjects.forEach(setAlias);
}
if (document.querySelector("script[data-prefixed-prototypes]")) {
var prefixProtoData = document.querySelector("script[data-prefixed-prototypes]").dataset["prefixedPrototypes"];
try {
var prefixedPrototypes = JSON.parse(prefixProtoData);
} catch (e) {
throw "couldn't parse data-prefixed-prototypes as JSON:" + e;
}
prefixedPrototypes.forEach(setPrototypeAlias);
}
var ul = document.createElement("ul");
Object.keys(aliases).forEach(function (alias) {
var li = document.createElement("li");
li.appendChild(document.createTextNode(alias + " has been set to be an alias of vendor-prefixed " + aliases[alias]));
ul.appendChild(li);
});
documentingPrefixUsage.appendChild(ul);
} else {
// Document that the test can be run with prefixes enabled
var a = document.createElement('a');
var link = "";
if (location.search) {
link = location.search + "&usePrefixes=1";
} else {
link = "?usePrefixes=1";
}
a.setAttribute("href", link);
a.appendChild(document.createTextNode("with vendor prefixes enabled"));
documentingPrefixUsage.appendChild(document.createTextNode("The feature(s) tested here are known to have been made available via vendor prefixes; you can run this test "));
documentingPrefixUsage.appendChild(a);
documentingPrefixUsage.appendChild(document.createTextNode("."));
}
var log = document.getElementById('log');
if (log) {
log.parentNode.insertBefore(documentingPrefixUsage, log);
} else {
document.body.appendChild(documentingPrefixUsage);
}
})();