mirror of
https://github.com/servo/servo.git
synced 2025-09-17 18:38:22 +01:00
Update web-platform-tests to revision 9c2bea6dac36e36ba1f489d10c2be42160d8f34f
This commit is contained in:
parent
482923cec2
commit
5c371dd958
459 changed files with 10717 additions and 834 deletions
|
@ -0,0 +1,262 @@
|
|||
function create_window_in_test(t, srcdoc) {
|
||||
let p = new Promise((resolve) => {
|
||||
let f = document.createElement('iframe');
|
||||
f.srcdoc = srcdoc ? srcdoc : '';
|
||||
f.onload = (event) => {
|
||||
let w = f.contentWindow;
|
||||
t.add_cleanup(() => f.remove());
|
||||
resolve(w);
|
||||
};
|
||||
document.body.appendChild(f);
|
||||
});
|
||||
return p;
|
||||
}
|
||||
|
||||
function test_with_window(f, name, srcdoc) {
|
||||
promise_test((t) => {
|
||||
return create_window_in_test(t, srcdoc)
|
||||
.then((w) => {
|
||||
f(w, w.document);
|
||||
});
|
||||
}, name);
|
||||
}
|
||||
|
||||
function define_custom_element_in_window(window, name, observedAttributes) {
|
||||
let log = [];
|
||||
|
||||
class CustomElement extends window.HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
log.push(create_constructor_log(this));
|
||||
}
|
||||
attributeChangedCallback(...args) {
|
||||
log.push(create_attribute_changed_callback_log(this, ...args));
|
||||
}
|
||||
connectedCallback() { log.push(create_connected_callback_log(this)); }
|
||||
disconnectedCallback() { log.push(create_disconnected_callback_log(this)); }
|
||||
adoptedCallback(oldDocument, newDocument) { log.push({type: 'adopted', element: this, oldDocument: oldDocument, newDocument: newDocument}); }
|
||||
}
|
||||
CustomElement.observedAttributes = observedAttributes;
|
||||
|
||||
window.customElements.define(name, CustomElement);
|
||||
|
||||
return {
|
||||
name: name,
|
||||
class: CustomElement,
|
||||
takeLog: function () {
|
||||
let currentLog = log; log = [];
|
||||
currentLog.types = () => currentLog.map((entry) => entry.type);
|
||||
currentLog.last = () => currentLog[currentLog.length - 1];
|
||||
return currentLog;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function create_constructor_log(element) {
|
||||
return {type: 'constructed', element: element};
|
||||
}
|
||||
|
||||
function assert_constructor_log_entry(log, element) {
|
||||
assert_equals(log.type, 'constructed');
|
||||
assert_equals(log.element, element);
|
||||
}
|
||||
|
||||
function create_connected_callback_log(element) {
|
||||
return {type: 'connected', element: element};
|
||||
}
|
||||
|
||||
function assert_connected_log_entry(log, element) {
|
||||
assert_equals(log.type, 'connected');
|
||||
assert_equals(log.element, element);
|
||||
}
|
||||
|
||||
function create_disconnected_callback_log(element) {
|
||||
return {type: 'disconnected', element: element};
|
||||
}
|
||||
|
||||
function assert_disconnected_log_entry(log, element) {
|
||||
assert_equals(log.type, 'disconnected');
|
||||
assert_equals(log.element, element);
|
||||
}
|
||||
|
||||
function assert_adopted_log_entry(log, element) {
|
||||
assert_equals(log.type, 'adopted');
|
||||
assert_equals(log.element, element);
|
||||
}
|
||||
|
||||
function create_adopted_callback_log(element) {
|
||||
return {type: 'adopted', element: element};
|
||||
}
|
||||
|
||||
function create_attribute_changed_callback_log(element, name, oldValue, newValue, namespace) {
|
||||
return {
|
||||
type: 'attributeChanged',
|
||||
element: element,
|
||||
name: name,
|
||||
namespace: namespace,
|
||||
oldValue: oldValue,
|
||||
newValue: newValue,
|
||||
actualValue: element.getAttributeNS(namespace, name)
|
||||
};
|
||||
}
|
||||
|
||||
function assert_attribute_log_entry(log, expected) {
|
||||
assert_equals(log.type, 'attributeChanged');
|
||||
assert_equals(log.name, expected.name);
|
||||
assert_equals(log.oldValue, expected.oldValue);
|
||||
assert_equals(log.newValue, expected.newValue);
|
||||
assert_equals(log.actualValue, expected.newValue);
|
||||
assert_equals(log.namespace, expected.namespace);
|
||||
}
|
||||
|
||||
|
||||
function define_new_custom_element(observedAttributes) {
|
||||
let log = [];
|
||||
let name = 'custom-element-' + define_new_custom_element._element_number++;
|
||||
|
||||
class CustomElement extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
log.push({type: 'constructed', element: this});
|
||||
}
|
||||
attributeChangedCallback(...args) {
|
||||
log.push(create_attribute_changed_callback_log(this, ...args));
|
||||
}
|
||||
connectedCallback() { log.push({type: 'connected', element: this}); }
|
||||
disconnectedCallback() { log.push({type: 'disconnected', element: this}); }
|
||||
adoptedCallback(oldDocument, newDocument) { log.push({type: 'adopted', element: this, oldDocument: oldDocument, newDocument: newDocument}); }
|
||||
}
|
||||
CustomElement.observedAttributes = observedAttributes;
|
||||
|
||||
customElements.define(name, CustomElement);
|
||||
|
||||
return {
|
||||
name: name,
|
||||
class: CustomElement,
|
||||
takeLog: function () {
|
||||
let currentLog = log; log = [];
|
||||
currentLog.types = () => currentLog.map((entry) => entry.type);
|
||||
currentLog.last = () => currentLog[currentLog.length - 1];
|
||||
return currentLog;
|
||||
}
|
||||
};
|
||||
}
|
||||
define_new_custom_element._element_number = 1;
|
||||
|
||||
function define_build_in_custom_element(observedAttributes, extendedElement, extendsOption) {
|
||||
let log = [];
|
||||
let name = 'custom-element-' + define_build_in_custom_element._element_number++;
|
||||
|
||||
class CustomElement extends extendedElement {
|
||||
constructor() {
|
||||
super();
|
||||
log.push({type: 'constructed', element: this});
|
||||
}
|
||||
attributeChangedCallback(...args) {
|
||||
log.push(create_attribute_changed_callback_log(this, ...args));
|
||||
}
|
||||
connectedCallback() { log.push({type: 'connected', element: this}); }
|
||||
disconnectedCallback() { log.push({type: 'disconnected', element: this}); }
|
||||
adoptedCallback(oldDocument, newDocument) { log.push({type: 'adopted', element: this, oldDocument: oldDocument, newDocument: newDocument}); }
|
||||
}
|
||||
CustomElement.observedAttributes = observedAttributes;
|
||||
customElements.define(name, CustomElement, { extends: extendsOption});
|
||||
|
||||
return {
|
||||
name: name,
|
||||
class: CustomElement,
|
||||
takeLog: function () {
|
||||
let currentLog = log; log = [];
|
||||
currentLog.types = () => currentLog.map((entry) => entry.type);
|
||||
currentLog.last = () => currentLog[currentLog.length - 1];
|
||||
return currentLog;
|
||||
}
|
||||
};
|
||||
}
|
||||
define_build_in_custom_element._element_number = 1;
|
||||
|
||||
function document_types() {
|
||||
return [
|
||||
{
|
||||
name: 'the document',
|
||||
create: function () { return Promise.resolve(document); },
|
||||
isOwner: true,
|
||||
hasBrowsingContext: true,
|
||||
},
|
||||
{
|
||||
name: 'the document of the template elements',
|
||||
create: function () {
|
||||
return new Promise(function (resolve) {
|
||||
var template = document.createElementNS('http://www.w3.org/1999/xhtml', 'template');
|
||||
var doc = template.content.ownerDocument;
|
||||
if (!doc.documentElement)
|
||||
doc.appendChild(doc.createElement('html'));
|
||||
resolve(doc);
|
||||
});
|
||||
},
|
||||
hasBrowsingContext: false,
|
||||
},
|
||||
{
|
||||
name: 'a new document',
|
||||
create: function () {
|
||||
return new Promise(function (resolve) {
|
||||
var doc = new Document();
|
||||
doc.appendChild(doc.createElement('html'));
|
||||
resolve(doc);
|
||||
});
|
||||
},
|
||||
hasBrowsingContext: false,
|
||||
},
|
||||
{
|
||||
name: 'a cloned document',
|
||||
create: function () {
|
||||
return new Promise(function (resolve) {
|
||||
var doc = document.cloneNode(false);
|
||||
doc.appendChild(doc.createElement('html'));
|
||||
resolve(doc);
|
||||
});
|
||||
},
|
||||
hasBrowsingContext: false,
|
||||
},
|
||||
{
|
||||
name: 'a document created by createHTMLDocument',
|
||||
create: function () {
|
||||
return Promise.resolve(document.implementation.createHTMLDocument());
|
||||
},
|
||||
hasBrowsingContext: false,
|
||||
},
|
||||
{
|
||||
name: 'an HTML document created by createDocument',
|
||||
create: function () {
|
||||
return Promise.resolve(document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null));
|
||||
},
|
||||
hasBrowsingContext: false,
|
||||
},
|
||||
{
|
||||
name: 'the document of an iframe',
|
||||
create: function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.onload = function () { resolve(iframe.contentDocument); }
|
||||
iframe.onerror = function () { reject('Failed to load an empty iframe'); }
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
},
|
||||
hasBrowsingContext: true,
|
||||
},
|
||||
{
|
||||
name: 'an HTML document fetched by XHR',
|
||||
create: function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'resources/empty-html-document.html');
|
||||
xhr.overrideMimeType('text/xml');
|
||||
xhr.onload = function () { resolve(xhr.responseXML); }
|
||||
xhr.onerror = function () { reject('Failed to fetch the document'); }
|
||||
xhr.send();
|
||||
});
|
||||
},
|
||||
hasBrowsingContext: false,
|
||||
}
|
||||
];
|
||||
}
|
|
@ -22,6 +22,14 @@
|
|||
}
|
||||
|
||||
Actions.prototype = {
|
||||
ButtonType: {
|
||||
LEFT: 0,
|
||||
MIDDLE: 1,
|
||||
RIGHT: 2,
|
||||
BACK: 3,
|
||||
FORWARD: 4,
|
||||
},
|
||||
|
||||
/**
|
||||
* Generate the action sequence suitable for passing to
|
||||
* test_driver.action_sequence
|
||||
|
@ -98,7 +106,7 @@
|
|||
* @returns {Actions}
|
||||
*/
|
||||
addKeyboard: function(name, set=true) {
|
||||
this.createSource("key", name, true);
|
||||
this.createSource("key", name);
|
||||
if (set) {
|
||||
this.setKeyboard(name);
|
||||
}
|
||||
|
@ -125,7 +133,7 @@
|
|||
* @returns {Actions}
|
||||
*/
|
||||
addPointer: function(name, pointerType="mouse", set=true) {
|
||||
this.createSource("pointer", name, true, {pointerType: pointerType});
|
||||
this.createSource("pointer", name, {pointerType: pointerType});
|
||||
if (set) {
|
||||
this.setPointer(name);
|
||||
}
|
||||
|
@ -225,7 +233,7 @@
|
|||
* pointer source
|
||||
* @returns {Actions}
|
||||
*/
|
||||
pointerDown: function({button=0, sourceName=null}={}) {
|
||||
pointerDown: function({button=this.ButtonType.LEFT, sourceName=null}={}) {
|
||||
let source = this.getSource("pointer", sourceName);
|
||||
source.pointerDown(this, button);
|
||||
return this;
|
||||
|
@ -239,7 +247,7 @@
|
|||
* source
|
||||
* @returns {Actions}
|
||||
*/
|
||||
pointerUp: function({button=0, sourceName=null}={}) {
|
||||
pointerUp: function({button=this.ButtonType.LEFT, sourceName=null}={}) {
|
||||
let source = this.getSource("pointer", sourceName);
|
||||
source.pointerUp(this, button);
|
||||
return this;
|
||||
|
|
|
@ -192,7 +192,7 @@
|
|||
* @returns {Promise} fufiled after the actions are performed, or rejected in
|
||||
* the cases the WebDriver command errors
|
||||
*/
|
||||
action_sequence(actions) {
|
||||
action_sequence: function(actions) {
|
||||
return window.test_driver_internal.action_sequence(actions);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue