mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255
This commit is contained in:
parent
b2a5225831
commit
1a81b18b9f
12321 changed files with 544385 additions and 6 deletions
|
@ -0,0 +1,15 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: getting on*</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
var events = ['open', 'message', 'error', 'close'];
|
||||
for (var i = 0; i < events.length; ++i) {
|
||||
test(function(){
|
||||
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
|
||||
assert_equals(ws['on'+events[i]], null, 'on'+events[i]);
|
||||
});
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,17 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: setting on*</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
var events = ['open', 'message', 'error', 'close'];
|
||||
for (var i = 0; i < events.length; ++i) {
|
||||
test(function(){
|
||||
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
|
||||
var foo = function () {};
|
||||
ws['on'+events[i]] = foo;
|
||||
assert_equals(ws['on'+events[i]], foo);
|
||||
});
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,19 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: listening for events with onopen</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
|
||||
var foo = t.step_func(function (e) {
|
||||
if (e.detail == 5)
|
||||
t.done();
|
||||
})
|
||||
ws.onopen = foo;
|
||||
var ev = document.createEvent('UIEvents');
|
||||
ev.initUIEvent('open', false, false, window, 5);
|
||||
ws.dispatchEvent(ev);
|
||||
}, null, {timeout:2000});
|
||||
</script>
|
|
@ -0,0 +1,14 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: members of EventTarget</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
test(function(){
|
||||
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
|
||||
assert_equals(typeof ws.addEventListener, 'function');
|
||||
assert_equals(typeof ws.removeEventListener, 'function');
|
||||
assert_equals(typeof ws.dispatchEvent, 'function');
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,15 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: 'on*' in ws</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
test(function(){
|
||||
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
|
||||
assert_equals('onopen' in ws, true, 'onopen');
|
||||
assert_equals('onmessage' in ws, true, 'onmessage');
|
||||
assert_equals('onerror' in ws, true, 'onerror');
|
||||
assert_equals('onclose' in ws, true, 'onclose');
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,19 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: listening for events with onmessage</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
|
||||
var foo = t.step_func(function (e) {
|
||||
if (e.detail == 5)
|
||||
t.done();
|
||||
})
|
||||
ws.onmessage = foo;
|
||||
var ev = document.createEvent('UIEvents');
|
||||
ev.initUIEvent('message', false, false, window, 5);
|
||||
ws.dispatchEvent(ev);
|
||||
}, null, {timeout:2000});
|
||||
</script>
|
|
@ -0,0 +1,22 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: listening for events with onerror</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
|
||||
var run = false;
|
||||
var foo = t.step_func(function (e) {
|
||||
run = true;
|
||||
assert_equals(e.detail, 5)
|
||||
});
|
||||
ws.onerror = foo;
|
||||
var ev = document.createEvent('UIEvents');
|
||||
ev.initUIEvent('error', false, false, window, 5);
|
||||
ws.dispatchEvent(ev);
|
||||
assert_true(run);
|
||||
t.done();
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,19 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: listening for events with onclose</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
|
||||
var foo = t.step_func(function (e) {
|
||||
if (e.detail == 5)
|
||||
t.done();
|
||||
});
|
||||
ws.onclose = foo;
|
||||
var ev = document.createEvent('UIEvents');
|
||||
ev.initUIEvent('close', false, false, window, 5);
|
||||
ws.dispatchEvent(ev);
|
||||
}, null, {timeout:2000});
|
||||
</script>
|
|
@ -0,0 +1,19 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: setting event handlers to undefined</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
var events = ['onclose', 'onopen', 'onerror', 'onmessage'];
|
||||
for (var i = 0; i < events.length; ++i) {
|
||||
test(function(){
|
||||
var ws = new WebSocket(SCHEME_AND_DOMAIN+'/');
|
||||
var foo = function() {}
|
||||
ws[events[i]] = foo;
|
||||
assert_equals(ws[events[i]], foo, events[i]);
|
||||
ws[events[i]] = undefined;
|
||||
assert_equals(ws[events[i]], null, events[i]);
|
||||
});
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,16 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: setting event handlers to 1</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
var events = ['onclose', 'onopen', 'onerror', 'onmessage'];
|
||||
for (var i = 0; i < events.length; ++i) {
|
||||
test(function(t) {
|
||||
var ws = new WebSocket(SCHEME_AND_DOMAIN+'/');
|
||||
ws[events[i]] = 1;
|
||||
assert_equals(ws[events[i]], null);
|
||||
}, events[i]);
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,16 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: setting event handlers to ";"</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
var events = ['onclose', 'onopen', 'onerror', 'onmessage'];
|
||||
for (var i = 0; i < events.length; ++i) {
|
||||
test(function(t) {
|
||||
var ws = new WebSocket(SCHEME_AND_DOMAIN+'/');
|
||||
ws[events[i]] = ";";
|
||||
assert_equals(ws[events[i]], null);
|
||||
}, events[i]);
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,16 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: setting event handlers to {handleEvent:function(){}}</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
var events = ['onclose', 'onopen', 'onerror', 'onmessage'];
|
||||
for (var i = 0; i < events.length; ++i) {
|
||||
test(function(t) {
|
||||
var ws = new WebSocket(SCHEME_AND_DOMAIN+'/');
|
||||
ws[events[i]] = {handleEvent:function(){}};
|
||||
assert_equals(ws[events[i]], null);
|
||||
}, events[i]);
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,19 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: setting event handlers to null</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
var events = ['onclose', 'onopen', 'onerror', 'onmessage'];
|
||||
for (var i = 0; i < events.length; ++i) {
|
||||
test(function() {
|
||||
var ws = new WebSocket(SCHEME_AND_DOMAIN+'/');
|
||||
var foo = function() {}
|
||||
ws[events[i]] = foo;
|
||||
assert_equals(ws[events[i]], foo, events[i]);
|
||||
ws[events[i]] = null;
|
||||
assert_equals(ws[events[i]], null, events[i]);
|
||||
}, "Setting event handlers to null " + events[i]);
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,31 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: instanceof on events</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo_raw');
|
||||
ws.onopen = t.step_func(function(e) {
|
||||
assert_true(e instanceof Event);
|
||||
// first a text frame, then a frame with reserved opcode 3
|
||||
// which should fail the connection
|
||||
ws.send('\\x81\\x04test\\x83\\x03LOL');
|
||||
});
|
||||
ws.onmessage = t.step_func(function(e) {
|
||||
assert_true(e instanceof Event);
|
||||
assert_true(e instanceof MessageEvent);
|
||||
assert_equals(ws.readyState, ws.OPEN);
|
||||
})
|
||||
ws.onerror = t.step_func(function(e) {
|
||||
assert_true(e instanceof Event);
|
||||
assert_equals(ws.readyState, ws.CLOSED);
|
||||
})
|
||||
ws.onclose = t.step_func(function(e) {
|
||||
assert_true(e instanceof Event);
|
||||
assert_true(e instanceof CloseEvent);
|
||||
t.done();
|
||||
})
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,35 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: addEventListener</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
|
||||
var count = 0;
|
||||
var checkCount = t.step_func(function (c, e) {
|
||||
count++;
|
||||
assert_equals(count, c);
|
||||
});
|
||||
// no spec requires this order for event listeners but the web does
|
||||
ws.addEventListener('open', t.step_func(function(e) {
|
||||
checkCount(1, e);
|
||||
ws.send('Goodbye');
|
||||
}), false);
|
||||
ws.onopen = t.step_func(function(e) {checkCount(2, e) });
|
||||
ws.addEventListener('open', t.step_func(function(e) {checkCount(3, e); }), false);
|
||||
|
||||
ws.addEventListener('message', t.step_func(function(e) {checkCount(4, e); }), false);
|
||||
ws.onmessage = t.step_func(function(e) {checkCount(5, e) });
|
||||
ws.addEventListener('message', t.step_func(function(e) {checkCount(6, e); }), false);
|
||||
|
||||
ws.addEventListener('close', t.step_func(function(e) {checkCount(7, e); }), false);
|
||||
ws.onclose = t.step_func(function(e) {checkCount(8, e) });
|
||||
ws.addEventListener('close', t.step_func(function(e) {
|
||||
checkCount(9, e);
|
||||
t.done();
|
||||
}), false);
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,51 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: this, e.target, e.currentTarget, e.eventPhase</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo_raw');
|
||||
ws.addEventListener('open', function(e) {
|
||||
var this_val = this;
|
||||
t.step(function() {
|
||||
// first a text frame, then a frame with reserved opcode 3
|
||||
// which should fail the connection
|
||||
ws.send('\\x81\\x04test\\x83\\x03LOL');
|
||||
assert_equals(this_val, ws);
|
||||
assert_equals(e.target, ws);
|
||||
assert_equals(e.currentTarget, ws);
|
||||
assert_equals(e.eventPhase, 2);
|
||||
});
|
||||
}, false);
|
||||
ws.addEventListener('message', function(e) {
|
||||
var this_val = this;
|
||||
t.step(function() {
|
||||
assert_equals(this_val, ws);
|
||||
assert_equals(e.target, ws);
|
||||
assert_equals(e.currentTarget, ws);
|
||||
assert_equals(e.eventPhase, 2);
|
||||
});
|
||||
}, false);
|
||||
ws.addEventListener('error', function(e) {
|
||||
var this_val = this;
|
||||
t.step(function() {
|
||||
assert_equals(this_val, ws);
|
||||
assert_equals(e.target, ws);
|
||||
assert_equals(e.currentTarget, ws);
|
||||
assert_equals(e.eventPhase, 2);
|
||||
});
|
||||
}, false);
|
||||
ws.addEventListener('close', function(e) {
|
||||
var this_val = this;
|
||||
t.step(function() {
|
||||
assert_equals(this_val, ws);
|
||||
assert_equals(e.target, ws);
|
||||
assert_equals(e.currentTarget, ws);
|
||||
assert_equals(e.eventPhase, 2);
|
||||
t.done();
|
||||
});
|
||||
}, false);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,35 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: toString(), bubbles, cancelable</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo_raw');
|
||||
ws.addEventListener('open', t.step_func(function(e) {
|
||||
// first a text frame, then a frame with reserved opcode 3
|
||||
// which should fail the connection
|
||||
ws.send('\\x81\\x04test\\x83\\x03LOL');
|
||||
assert_equals(e.toString(), '[object Event]', "open e.toString()");
|
||||
assert_equals(e.bubbles, false, 'open e.bubbles');
|
||||
assert_equals(e.cancelable, false, 'open e.cancelable');
|
||||
}), false);
|
||||
ws.addEventListener('message', t.step_func(function(e) {
|
||||
assert_equals(e.toString(), '[object MessageEvent]', "message e.toString()");
|
||||
assert_equals(e.bubbles, false, 'message e.bubbles');
|
||||
assert_equals(e.cancelable, false, 'message e.cancelable');
|
||||
}), false);
|
||||
ws.addEventListener('error', t.step_func(function(e) {
|
||||
assert_equals(e.toString(), '[object Event]', "error e.toString()");
|
||||
assert_equals(e.bubbles, false, 'error e.bubbles');
|
||||
assert_equals(e.cancelable, false, 'error e.cancelable');
|
||||
}), false);
|
||||
ws.addEventListener('close', t.step_func(function(e) {
|
||||
assert_equals(e.toString(), '[object CloseEvent]', "close e.toString()");
|
||||
assert_equals(e.bubbles, false, 'close e.bubbles');
|
||||
assert_equals(e.cancelable, false, 'close e.cancelable');
|
||||
t.done();
|
||||
}), false);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,29 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: removeEventListener</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
var events = ['open', 'message', 'error', 'close'];
|
||||
for (var i = 0; i < events.length; ++i) {
|
||||
test(function(t) {
|
||||
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
|
||||
ws.close();
|
||||
var got = [];
|
||||
var event;
|
||||
function addThis(e) {
|
||||
got.push(e.type);
|
||||
}
|
||||
ws.addEventListener(events[i], addThis, false);
|
||||
ws.removeEventListener(events[i], addThis, false);
|
||||
event = document.createEvent('Event');
|
||||
event.initEvent(events[i], false, false);
|
||||
ws.dispatchEvent(event);
|
||||
assert_equals(got.length, 0);
|
||||
if (got.length) {
|
||||
debug('Got: '+got);
|
||||
}
|
||||
})
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,15 @@
|
|||
<!doctype html>
|
||||
<title>WebSockets: error events</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=../../../constants.js?pipe=sub></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var ws = new WebSocket('ws://example.invalid/');
|
||||
ws.onerror = t.step_func(function(e) {
|
||||
assert_true(e instanceof Event);
|
||||
t.done();
|
||||
})
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue