Use "_self" as a default target for getURL when no target is given. Fixes bug #32425
[gnash.git] / testsuite / actionscript.all / XMLSocket.as
blob7cfd48d1c4a083393ee4af9887b078704b9edcf4
1 //
2 // Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 // Test case for Function ActionScript class
20 // compile this test case with Ming makeswf, and then
21 // execute it like this gnash -1 -r 0 -v out.swf
23 // The attempted connections here should always fail. See
24 // misc-ming.all/XMLSocketTest.c and testsuite/XmlSocketServer.pl
25 // for tests with a running server.
27 rcsid="$Id: XMLSocket.as,v 1.10 2008/04/01 09:26:54 strk Exp $";
28 #include "check.as"
30 #if OUTPUT_VERSION < 6
31 XMLSocket.prototype.hasOwnProperty = ASnative(101, 5);
32 #endif
34 check(XMLSocket.prototype.hasOwnProperty("connect"));
35 check(XMLSocket.prototype.hasOwnProperty("send"));
36 check(XMLSocket.prototype.hasOwnProperty("close"));
37 check(XMLSocket.prototype.hasOwnProperty("onData"));
39 check(!XMLSocket.prototype.hasOwnProperty("onXML"));
40 check(!XMLSocket.prototype.hasOwnProperty("onConnect"));
41 check(!XMLSocket.prototype.hasOwnProperty("onClose"));
44 check_equals(typeof(XMLSocket), 'function');
45 check_equals(typeof(XMLSocket.connect), 'undefined');
46 check_equals(typeof(XMLSocket.close), 'undefined');
47 check_equals(typeof(XMLSocket.send), 'undefined');
48 check_equals(typeof(XMLSocket.Connected), 'undefined');
49 check_equals(typeof(XMLSocket.connected), 'undefined');
51 check_equals(typeof(XMLSocket.prototype.connect), 'function');
52 check_equals(typeof(XMLSocket.prototype.close), 'function');
53 check_equals(typeof(XMLSocket.prototype.send), 'function');
54 check_equals(typeof(XMLSocket.prototype.Connected), 'undefined');
55 check_equals(typeof(XMLSocket.prototype.connected), 'undefined');
58 socketObj = new XMLSocket;
60 // The default onData handler calls onXML after parsing the code
61 check_equals(typeof(socketObj.onData), 'function');
63 check_equals(typeof(socketObj), 'object');
64 check_equals(socketObj.__proto__, XMLSocket.prototype);
65 check( ! socketObj.hasOwnProperty('connect') );
66 check( ! socketObj.hasOwnProperty('close') );
67 check( ! socketObj.hasOwnProperty('send') );
69 socketObj.secret = 4;
71 socketObj.onConnect = function(success) {
72 check_equals(this.secret, 4);
73 if ( success )
75 note("XMLSocket.onConnect(success) called");
77 else
79 note("XMLSocket.onConnect(failure) called");
84 socketObj.onXML = function(x) {
85 check_equals(this.secret, 4);
86 check_equals(arguments.length, 1);
87 check(x instanceof XML);
88 note("XMLSocket.onXML() called with a "+typeof(arguments[0])+" as arg");
89 note("Parsed XML: "+x.toString());
92 socketObj.onClose = function() {
93 check_equals(this.secret, 4);
94 note("XMLSocket.onClose() called with "+arguments.length);
97 host = 'madeuphost';
98 port = 1090929898;
100 // Connect should fail
101 check_equals(socketObj.connect(host, port), false);
102 // And again
103 check_equals(socketObj.connect(host, port), false);
105 // Close returns undefined, and we'd like not to crash if we call
106 // close when not connected.
107 ret = socketObj.close();
108 check_equals(ret, undefined);
109 // And again.
110 ret = socketObj.close();
111 check_equals(ret, undefined);
113 ret = socketObj.send("This won't work'");
114 check_equals(ret, undefined);
116 totals(29);