Update web-platform-tests to revision d04a8fc02b85bd32799691759c8c05ead07cd939

This commit is contained in:
WPT Sync Bot 2018-03-23 21:12:55 -04:00
parent e8fdc677f4
commit 2b35c55ac7
63 changed files with 2068 additions and 340 deletions

View file

@ -24,8 +24,8 @@ def pytest_configure(config):
config.driver = webdriver.Firefox(firefox_binary=config.getoption("--binary"))
config.server = WPTServer(WPT_ROOT)
config.server.start()
config.add_cleanup(lambda: config.server.stop())
config.add_cleanup(lambda: config.driver.quit())
config.add_cleanup(config.server.stop)
config.add_cleanup(config.driver.quit)
class HTMLItem(pytest.Item, pytest.Collector):
def __init__(self, filename, parent):

View file

@ -12,7 +12,7 @@
<body>
<script>
"use strict";
function wrap(obj) {
function wrap(member, obj) {
function F(obj) {
this._obj = obj;
}
@ -20,25 +20,25 @@
F.prototype.toJSON = function() {
return this._obj;
}
Object.defineProperty(F, 'name', { value: member.name });
return new F(obj);
}
var i, obj;
i = interfaceFrom("interface A { [Default] object toJSON(); attribute long foo; };");
i.test_to_json_operation(wrap({ foo: 123 }), i.members[0]);
i.test_to_json_operation(wrap(i, { foo: 123 }), i.members[0]);
// should fail (wrong type)
i = interfaceFrom("interface B { [Default] object toJSON(); attribute long foo; };");
i.test_to_json_operation(wrap({ foo: "a value" }), i.members[0]);
i.test_to_json_operation(wrap(i, { foo: "a value" }), i.members[0]);
// should handle extraneous attributes (e.g. from an extension specification)
i = interfaceFrom("interface C { [Default] object toJSON(); attribute long foo; };");
i.test_to_json_operation(wrap({ foo: 123, bar: 456 }), i.members[0]);
i.test_to_json_operation(wrap(i, { foo: 123, bar: 456 }), i.members[0]);
// should fail (missing property)
i = interfaceFrom("interface D { [Default] object toJSON(); attribute long foo; };");
i.test_to_json_operation(wrap({ }), i.members[0]);
i.test_to_json_operation(wrap(i, { }), i.members[0]);
// should fail (should be writable)
obj = Object.defineProperties({}, { foo: {
@ -48,7 +48,7 @@
value: 123
}});
i = interfaceFrom("interface F { [Default] object toJSON(); attribute long foo; };");
i.test_to_json_operation(wrap(obj), i.members[0]);
i.test_to_json_operation(wrap(i, obj), i.members[0]);
// should fail (should be enumerable)
obj = Object.defineProperties({}, { foo: {
@ -58,7 +58,7 @@
value: 123
}});
i = interfaceFrom("interface G { [Default] object toJSON(); attribute long foo; };");
i.test_to_json_operation(wrap(obj), i.members[0]);
i.test_to_json_operation(wrap(i, obj), i.members[0]);
// should fail (should be configurable)
obj = Object.defineProperties({}, { foo: {
@ -68,27 +68,27 @@
value: 123
}});
i = interfaceFrom("interface H { [Default] object toJSON(); attribute long foo; };");
i.test_to_json_operation(wrap(obj), i.members[0]);
i.test_to_json_operation(wrap(i, obj), i.members[0]);
var idl = new IdlArray();
idl.add_idls("interface I : J { [Default] object toJSON(); attribute long foo; };");
idl.add_idls("interface J { [Default] object toJSON(); attribute DOMString foo;};");
var i = idl.members.I;
i.test_to_json_operation(wrap({ foo: 123 }), i.members[0]);
i.test_to_json_operation(wrap(i, { foo: 123 }), i.members[0]);
i = interfaceFrom("interface K { [Default] object toJSON(); };");
i.test_to_json_operation(wrap({}), i.members[0]);
i.test_to_json_operation(wrap(i, {}), i.members[0]);
i = interfaceFrom("interface L { DOMString toJSON(); };");
i.test_to_json_operation(wrap("a string"), i.members[0]);
i.test_to_json_operation(wrap(i, "a string"), i.members[0]);
// should fail (wrong output type)
i = interfaceFrom("interface M { DOMString toJSON(); };");
i.test_to_json_operation(wrap({}), i.members[0]);
i.test_to_json_operation(wrap(i, {}), i.members[0]);
// should fail (not an IDL type)
i = interfaceFrom("interface N { DOMException toJSON(); };");
i.test_to_json_operation(wrap({}), i.members[0]);
i.test_to_json_operation(wrap(i, {}), i.members[0]);
</script>
<script type="text/json" id="expected">
{

View file

@ -1,48 +1,49 @@
import json
import os
import ssl
import subprocess
import time
import urllib2
_CONFIG_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'config.test.json')
with open(_CONFIG_FILE, 'r') as config_handle:
config = json.loads(config_handle.read())
host = config["host"]
port = config["ports"]["https"][0]
class WPTServer(object):
base_url = 'https://%s:%s' % (host, port)
def __init__(self, wpt_root):
self.wpt_root = wpt_root
with open(_CONFIG_FILE, 'r') as config_handle:
config = json.load(config_handle)
self.host = config["host"]
self.http_port = config["ports"]["http"][0]
self.https_port = config["ports"]["https"][0]
self.base_url = 'http://%s:%s' % (self.host, self.http_port)
self.https_base_url = 'https://%s:%s' % (self.host, self.https_port)
def start(self):
self.devnull = open(os.devnull, 'w')
self.proc = subprocess.Popen(
[os.path.join(self.wpt_root, 'wpt'), 'serve', '--config=' + _CONFIG_FILE],
stdout=self.devnull,
stderr=self.devnull,
cwd=self.wpt_root)
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
context.verify_mode = ssl.CERT_NONE
context.check_hostname = False
while True:
for retry in range(5):
# Exponential backoff.
time.sleep(2 ** retry)
if self.proc.poll() != None:
raise Exception('Could not start wptserve.')
try:
urllib2.urlopen(self.base_url, timeout=1, context=context)
break
except urllib2.URLError as e:
try:
urllib2.urlopen(self.base_url, timeout=1)
return
except urllib2.URLError:
pass
raise Exception('Could not start wptserve.')
def stop(self):
self.proc.kill()
self.proc.terminate()
self.proc.wait()
self.devnull.close()
def url(self, abs_path):
return self.base_url + '/' + os.path.relpath(abs_path, self.wpt_root)
return self.https_base_url + '/' + os.path.relpath(abs_path, self.wpt_root)