blob: b8a3b4ae6902357cfe392c484e8413bff1729061 [file] [log] [blame]
Hallvord R. M. Steenfe69bb42014-11-10 22:35:191<!doctype html>
2<meta charset=utf-8>
3<title>XMLHttpRequest: passing objects that interfere with the XHR instance to send()</title>
4<script src="/resources/testharness.js"></script>
5<script src="/resources/testharnessreport.js"></script>
Hallvord R. M. Steen7b400412014-11-11 12:00:546<link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::ol/li[4]" />
7<link rel="help" href="https://heycam.github.io/webidl/#es-union" data-tested-assertations="following::ol/li[16]" />
8
Hallvord R. M. Steenfe69bb42014-11-10 22:35:199
10<div id="log"></div>
11
12<script>
13 var test1 = async_test('abort() called from data stringification')
14 test1.step(function() {
15 var client = new XMLHttpRequest()
16 var objAbortsOnStringification = {toString:function(){
17 client.abort();
18 }}
19 client.open('POST', 'resources/content.py')
Anne van Kesteren06ae26c2016-10-24 13:05:1720 client.send(objAbortsOnStringification)
21 assert_equals(client.readyState, 1)
Hallvord R. M. Steenfe69bb42014-11-10 22:35:1922 test1.done()
23 });
24
25 var test2 = async_test('open() called from data stringification')
26 test2.step(function() {
27 var client = new XMLHttpRequest()
28 var objOpensOnStringification = {toString:function(){
29 client.open('POST', 'resources/status.py?text=second_open_wins');
30 }}
31 client.onloadend = test2.step_func(function(){
32 assert_equals(client.statusText, 'second_open_wins')
33 test2.done()
34 })
Hallvord R. M. Steen7b400412014-11-11 12:00:5435 client.open('POST', 'resources/status.py?text=first_open_wins')
Hallvord R. M. Steenfe69bb42014-11-10 22:35:1936 client.send(objOpensOnStringification)
37 });
38
39 var test3 = async_test('send() called from data stringification')
40 test3.step(function() {
41 var client = new XMLHttpRequest()
42 var objSendsOnStringification = {toString:function(){
43 client.send('bomb!');
44 }}
45 client.onload = test3.step_func(function(){
46 assert_equals(client.responseText, 'bomb!')
47 test3.done()
48 })
49 client.open('POST', 'resources/content.py')
50 assert_throws('InvalidStateError', function(){
51 client.send(objSendsOnStringification)
52 })
53 });
54
55
56</script>