001: package com.sun.portal.rewriter.engines.js.test;
002:
003: import com.sun.portal.rewriter.RewriterModule;
004: import com.sun.portal.rewriter.test.util.BasicTestCase;
005: import com.sun.portal.rewriter.test.util.JSWrapperHelper;
006: import com.sun.portal.rewriter.test.util.JScriptInterpreter;
007: import com.sun.portal.rewriter.util.StringHelper;
008: import junit.framework.TestSuite;
009:
010: public class TestJSConvertExpressionFunction extends BasicTestCase {
011: private static final String[][] data = {
012: {
013: "/irj/servlet/prt/portal/prtroot/com.sap.portal.appdesigner.framework.tabcontent?calcProperties=false&url=com.sap.portal.appdesigner.framework.contentStudioWelcomePage&dynamicButtonsUrl=&propEditor=false&actionButtons=false&objectID=Welcome_Page_ID&editorID=0&displayName=Overview&sessionID=20031105172526&",
014: "http://rajanagendra.sun.com/irj/servlet/prt/portal/prtroot/com.sap.portal.appdesigner.framework.tabcontent?calcProperties=false&url=com.sap.portal.appdesigner.framework.contentStudioWelcomePage&dynamicButtonsUrl=&propEditor=false&actionButtons=false&objectID=Welcome_Page_ID&editorID=0&displayName=Overview&sessionID=20031105172526&", },
015:
016: {
017: "/mail/mstm.nsf/iNotes/Proxy/?OpenDocument&Form=s_ReadViewEntries&PresetFields=FolderName;%28%24Inbox%29,s_UsingHttps;1&Start=1&Count=40",
018: "http://rajanagendra.sun.com/mail/mstm.nsf/iNotes/Proxy/?OpenDocument&Form=s_ReadViewEntries&PresetFields=FolderName;%28%24Inbox%29,s_UsingHttps;1&Start=1&Count=40", },
019:
020: {
021: "/command.shtml?view=overview&id=bu95rq3r35uq62n2o2p&crc=/()'-/*(+/&group=Keine+Kalendergruppe&date=",
022: "http://rajanagendra.sun.com/command.shtml?view=overview&id=bu95rq3r35uq62n2o2p&crc=/()'-/*(+/&group=Keine+Kalendergruppe&date=" },
023:
024: {
025: "command.shtml?view=overview&id=bu95rq3r35uq62n2o2p&crc=/()'-/*(+/&group=Keine+Kalendergruppe&date=",
026: "http://rajanagendra.sun.com/Base/Raja/command.shtml?view=overview&id=bu95rq3r35uq62n2o2p&crc=/()'-/*(+/&group=Keine+Kalendergruppe&date=" },
027:
028: {
029: "./?Cmd=navbar",
030: "http://rajanagendra.sun.com/Base/Raja/./?Cmd=navbar", },
031:
032: {
033: "/console/actions/mbean/MBeanFramesetAction?isNew=false&sidebarFrameId=wl_console_frame_1035263303090&frameId=wl_console_frame_1035263303091&MBean=portaldomain%3AName%3Dportaldomain%2CType%3DDomain&bodyFrameId=wl_console_frame_1035263303092",
034: "http://rajanagendra.sun.com/console/actions/mbean/MBeanFramesetAction?isNew=false&sidebarFrameId=wl_console_frame_1035263303090&frameId=wl_console_frame_1035263303091&MBean=portaldomain%3AName%3Dportaldomain%2CType%3DDomain&bodyFrameId=wl_console_frame_1035263303092", },
035:
036: {
037: "/command.shtml?view=new_cal&id=ebm0q3u6y92m2nv9&crc=3002401687&date=20021005T013040&newCalCalID=tuser&tzid=&e_ACL=@@o^c^WDEIC^g;@@o^a^RSF^g;@^a^sf^g;@^c^^g;@^p^r^g&freebusy=1&tab=1&prevView=monthview&calid=tuser&security=1",
038: "http://rajanagendra.sun.com/command.shtml?view=new_cal&id=ebm0q3u6y92m2nv9&crc=3002401687&date=20021005T013040&newCalCalID=tuser&tzid=&e_ACL=@@o^c^WDEIC^g;@@o^a^RSF^g;@^a^sf^g;@^c^^g;@^p^r^g&freebusy=1&tab=1&prevView=monthview&calid=tuser&security=1" },
039: {
040: "/command.shtml?view=new_cal&id=ebm0q3u6y92m2nv9&crc=3002401687&date=20021005T013040&newCalCalID=tuser&tzid=&e_ACL=@@o^c^WDEIC^g;@@o^a^RSF^g;@^a^sf^g;@^c^^g;@^p^r^g&freebusy=1&tab=1&prevView=monthview&calid=tuser&security=1",
041: "http://rajanagendra.sun.com/command.shtml?view=new_cal&id=ebm0q3u6y92m2nv9&crc=3002401687&date=20021005T013040&newCalCalID=tuser&tzid=&e_ACL=@@o^c^WDEIC^g;@@o^a^RSF^g;@^a^sf^g;@^c^^g;@^p^r^g&freebusy=1&tab=1&prevView=monthview&calid=tuser&security=1", },
042: { "/", "http://rajanagendra.sun.com/" },
043:
044: { "https://rajanagendra.sun.com:443 ",
045: "https://rajanagendra.sun.com " },
046: { " https://rajanagendra.sun.com:443",
047: " https://rajanagendra.sun.com" },
048: { " https://rajanagendra.sun.com:443 ",
049: " https://rajanagendra.sun.com " },
050:
051: { "file:///c:/ghkim/love.txt", "file:///c:/ghkim/love.txt" },
052: {
053: "./EP_SgPgLayView.jsp?pgid=|1E2652&titfont=white",
054: "http://rajanagendra.sun.com/Base/Raja/./EP_SgPgLayView.jsp?pgid=|1E2652&titfont=white" },
055: { "#default#homepage", "#default#homepage" }, //This is part of CSS Spec of browser, hence browser does not make network request for this. Hence leave this as is
056: {
057: "/first.shtml?view=new_cal&id=bl02oe8w2rbhp3t6&crc=2561871368&date=20020925T180701&newCalCalID=tuser&tzid=&freebusy=1&tab=1&prevView=monthview&calid=tuser&security=1",
058: "http://rajanagendra.sun.com/first.shtml?view=new_cal&id=bl02oe8w2rbhp3t6&crc=2561871368&date=20020925T180701&newCalCalID=tuser&tzid=&freebusy=1&tab=1&prevView=monthview&calid=tuser&security=1" },
059:
060: { "", "" }, //BugNo:4333395
061: { "''", "''" }, //135
062: { "\"\"", "\"\"" }, //135
063:
064: { "/abc.com", "http://rajanagendra.sun.com/abc.com" },
065: { " /abc.com ",
066: " http://rajanagendra.sun.com/abc.com " },
067: { " \t\t /abc.com ",
068: " \t\t http://rajanagendra.sun.com/abc.com " },
069: { " \r/abc.com ",
070: " \rhttp://rajanagendra.sun.com/abc.com " },
071: { " \n/abc.com ",
072: " \nhttp://rajanagendra.sun.com/abc.com " },
073:
074: {
075: "/abc.com?url=http://pserv6.sun.com/exchange/index.html",
076: "http://rajanagendra.sun.com/abc.com?url=http://pserv6.sun.com/exchange/index.html" },
077: {
078: "abc.com?url=http://pserv6.sun.com/exchange/index.html",
079: "http://rajanagendra.sun.com/Base/Raja/abc.com?url=http://pserv6.sun.com/exchange/index.html" },
080: {
081: "abc.comurl=http://pserv6.sun.com/exchange/index.html",
082: "http://rajanagendra.sun.com/Base/Raja/abc.comurl=http://pserv6.sun.com/exchange/index.html" },
083:
084: { "/http://pserv6.sun.com/exchange/index.html",
085: "http://rajanagendra.sun.com/http://pserv6.sun.com/exchange/index.html" },
086: {
087: " /abc.com?url=http://pserv6.sun.com/exchange/index.html",
088: " http://rajanagendra.sun.com/abc.com?url=http://pserv6.sun.com/exchange/index.html" },
089: {
090: "\t\t/abc.com?url=http://pserv6.sun.com/exchange/index.html",
091: "\t\thttp://rajanagendra.sun.com/abc.com?url=http://pserv6.sun.com/exchange/index.html" },
092:
093: { "\\\"\\14c.html\\\"",
094: "\\\"\\http://rajanagendra.sun.com/Base/Raja/14c.html\\\"" }, //0
095: { "\\\"\\raj\\k\\14c.html\\\"",
096: "\\\"\\http://rajanagendra.sun.com/Base/Raja/raj\\k\\14c.html\\\"" }, //0
097: { "\\\"raj\\k/14c.html\\\"",
098: "\\\"http://rajanagendra.sun.com/Base/Raja/raj\\k/14c.html\\\"" }, //0
099: { "\\\"/14c.html\\\"",
100: "\\\"http://rajanagendra.sun.com/14c.html\\\"" }, //0
101: { "\\\'/14c.html\\\'",
102: "\\\'http://rajanagendra.sun.com/14c.html\\\'" }, //1
103: { "\\'./14c.html\\'",
104: "\\'http://rajanagendra.sun.com/Base/Raja/./14c.html\\'" }, //2
105: { "\"\\\'./14c.html\\'",
106: "\"\\\'http://rajanagendra.sun.com/Base/Raja/./14c.html\\'" }, //3
107: { "\"/14c.html\"",
108: "\"http://rajanagendra.sun.com/14c.html\"" }, //4
109: { "'../14c.html'",
110: "'http://rajanagendra.sun.com/Base/Raja/../14c.html'" }, //5
111: { "'\"/14c.html\"'",
112: "'\"http://rajanagendra.sun.com/14c.html\"'" }, //6
113: { "'\\\"/14c.html\\\"'",
114: "'\\\"http://rajanagendra.sun.com/14c.html\\\"'" }, //7
115:
116: { "/14c.html\\\"",
117: "http://rajanagendra.sun.com/14c.html\\\"" }, //0
118: { "/14c.html\\\'",
119: "http://rajanagendra.sun.com/14c.html\\\'" }, //1
120: { "./14c.html\\'",
121: "http://rajanagendra.sun.com/Base/Raja/./14c.html\\'" }, //2
122: { "./14c.html\\'",
123: "http://rajanagendra.sun.com/Base/Raja/./14c.html\\'" }, //3
124: { "/14c.html\"", "http://rajanagendra.sun.com/14c.html\"" }, //4
125: { "../14c.html'",
126: "http://rajanagendra.sun.com/Base/Raja/../14c.html'" }, //5
127: { "/14c.html\"'", "http://rajanagendra.sun.com/14c.html\"'" }, //6
128: { "/14c.html\\\"'",
129: "http://rajanagendra.sun.com/14c.html\\\"'" }, //7
130:
131: { "\\\"/14c.html",
132: "\\\"http://rajanagendra.sun.com/14c.html" }, //0
133: { "\\\'/14c.html",
134: "\\\'http://rajanagendra.sun.com/14c.html" }, //1
135: { "\\'./14c.html",
136: "\\'http://rajanagendra.sun.com/Base/Raja/./14c.html" }, //2
137: { "\"\\\'./14c.html",
138: "\"\\\'http://rajanagendra.sun.com/Base/Raja/./14c.html" }, //3
139: { "\"/14c.html", "\"http://rajanagendra.sun.com/14c.html" }, //4
140: { "'../14c.html",
141: "'http://rajanagendra.sun.com/Base/Raja/../14c.html" }, //24
142: { "'\"/14c.html", "'\"http://rajanagendra.sun.com/14c.html" }, //6
143: { "'\\\"/14c.html",
144: "'\\\"http://rajanagendra.sun.com/14c.html" }, //7
145:
146: { "'''\t\t/index.html'''",
147: "'''\t\thttp://rajanagendra.sun.com/index.html'''" }, //30
148: { "'\t\t'\t'/index.html'''",
149: "'\t\t'\t'http://rajanagendra.sun.com/index.html'''" }, //30
150: { "'\t'\t'\t/index.html'''",
151: "'\t'\t'\thttp://rajanagendra.sun.com/index.html'''" }, //30
152: { "\t\"\t\"\t\"\t/index1.html\"\"\"",
153: "\t\"\t\"\t\"\thttp://rajanagendra.sun.com/index1.html\"\"\"" }, //30
154: { "\" \" \" \t /index.html\"\"\"",
155: "\" \" \" \t http://rajanagendra.sun.com/index.html\"\"\"" }, //30
156: { "\"\t\t\"\t\t\t\"\t\t\t\t/index.html\"\"\"",
157: "\"\t\t\"\t\t\t\"\t\t\t\thttp://rajanagendra.sun.com/index.html\"\"\"" }, //30
158: { "'''\t\t/index.html\t'\t'\t'",
159: "'''\t\thttp://rajanagendra.sun.com/index.html\t'\t'\t'" }, //30
160: { "'\t\t'\t'/index.html\t'\t\t''\t\t",
161: "'\t\t'\t'http://rajanagendra.sun.com/index.html\t'\t\t''\t\t" }, //30
162: { "'\t'\t'\t/index.html\t'\t'\t'\t",
163: "'\t'\t'\thttp://rajanagendra.sun.com/index.html\t'\t'\t'\t" }, //30
164: { "\t\"\t\"\t\"\t/index.html\t \" \t \"\t \"",
165: "\t\"\t\"\t\"\thttp://rajanagendra.sun.com/index.html\t \" \t \"\t \"" }, //37
166: { "\" \" \" \t /index.html \t \" \" \" ",
167: "\" \" \" \t http://rajanagendra.sun.com/index.html \t \" \" \" " }, //38
168: { "\"\t\t\"\t\t\"\t\t\t\t/index.html \" \" \" ",
169: "\"\t\t\"\t\t\"\t\t\t\thttp://rajanagendra.sun.com/index.html \" \" \" " }, //39
170: {
171: "\"\t\t\"\t\t\"\t\t\t\thttp://rajanagendra.sun.com/index.html \" \" \"",
172: "\"\t\t\"\t\t\"\t\t\t\thttp://rajanagendra.sun.com/index.html \" \" \"" }, //30
173: {
174: "\"\t\t\"\t\t\"\t\t\t\thttp://rajanagendra.sun.com:80/index.html \" \" \"",
175: "\"\t\t\"\t\t\"\t\t\t\thttp://rajanagendra.sun.com/index.html \" \" \"" }, //30
176: {
177: "\"\t\t\"\t\t\"\t\t\t\thttps://rajanagendra.sun.com:80/index1.html \" \" \"",
178: "\"\t\t\"\t\t\"\t\t\t\thttps://rajanagendra.sun.com:80/index1.html \" \" \"" }, //30
179: { "'/index.html'",
180: "'http://rajanagendra.sun.com/index.html'" }, //30
181: { "\"\"\"/index.html\"\"\"",
182: "\"\"\"http://rajanagendra.sun.com/index.html\"\"\"" }, //30
183: { "'''/index.html'''",
184: "'''http://rajanagendra.sun.com/index.html'''" }, //30
185:
186: { " #raj.index ", " #raj.index " }, //7
187: { " \"\'#raj.index\'\" ", " \"\'#raj.index\'\" " }, //7
188: {
189: "https://www.sun.com:443#https://www.sun.com:443/sh.html",
190: "https://www.sun.com#https://www.sun.com:443/sh.html" }, //16
191: {
192: "https://www.sun.com:443?https://www.sun.com:443/sh.html",
193: "https://www.sun.com?https://www.sun.com:443/sh.html" }, //16
194: { "https://www.sun.com/https://www.sun.com:443/sh.html",
195: "https://www.sun.com/https://www.sun.com:443/sh.html" }, //16
196: {
197: "https://www.sun.com:443/https://www.sun.com:443/sh.html",
198: "https://www.sun.com/https://www.sun.com:443/sh.html" }, //16
199: {
200: "http://www.sun.com:8680/sh.html?http://www.sun.com:443/sh.html",
201: "http://www.sun.com:8680/sh.html?http://www.sun.com:443/sh.html" }, //16
202: {
203: "http://www.sun.com:8086/sh.html?http://www.sun.com:443/sh.html",
204: "http://www.sun.com:8086/sh.html?http://www.sun.com:443/sh.html" }, //16
205: {
206: "http://www.sun.com:8080/sh.html?http://www.sun.com:443/sh.html",
207: "http://www.sun.com:8080/sh.html?http://www.sun.com:443/sh.html" }, //16
208: {
209: "https://www.sun.com:4431/sh.html?http://www.sun.com:443/sh.html",
210: "https://www.sun.com:4431/sh.html?http://www.sun.com:443/sh.html" }, //16
211: {
212: "https://www.sun.com:443/sh.html?http://www.sun.com:443/sh.html",
213: "https://www.sun.com/sh.html?http://www.sun.com:443/sh.html" }, //16
214: {
215: "https://www.sun.com/sh.html?http://www.sun.com:443/sh.html",
216: "https://www.sun.com/sh.html?http://www.sun.com:443/sh.html" }, //16
217:
218: { "ftp://rajanagendra.sun.com:21",
219: "ftp://rajanagendra.sun.com:21" },
220: { "file://rajanagendra.sun.com:0",
221: "file://rajanagendra.sun.com:0" },
222: { "https://rajanagendra.sun.com:443",
223: "https://rajanagendra.sun.com" },
224: { "http://rajanagendra.sun.com:80",
225: "http://rajanagendra.sun.com" },
226:
227: { "ftp://rajanagendra.sun.com:21 ",
228: "ftp://rajanagendra.sun.com:21 " },
229: { "file://rajanagendra.sun.com:0 ",
230: "file://rajanagendra.sun.com:0 " },
231: { "http://rajanagendra.sun.com:80 ",
232: "http://rajanagendra.sun.com " },
233:
234: { "file://rajanagendra.sun.com:0/",
235: "file://rajanagendra.sun.com:0/" },
236: { "ftp://rajanagendra.sun.com:21/",
237: "ftp://rajanagendra.sun.com:21/" },
238: { "https://rajanagendra.sun.com:443/",
239: "https://rajanagendra.sun.com/" },
240: { "http://rajanagendra.sun.com:80/",
241: "http://rajanagendra.sun.com/" },
242:
243: { "ftp://rajanagendra.sun.com:21/test.html",
244: "ftp://rajanagendra.sun.com:21/test.html" },
245: { "file://rajanagendra.sun.com:0/test.html",
246: "file://rajanagendra.sun.com:0/test.html" },
247: { "https://rajanagendra.sun.com:443/test.html",
248: "https://rajanagendra.sun.com/test.html" },
249: { "http://rajanagendra.sun.com:80/test.html",
250: "http://rajanagendra.sun.com/test.html" },
251:
252: { "file://rajanagendra.sun.com:0/test.html?index=21#ref",
253: "file://rajanagendra.sun.com:0/test.html?index=21#ref" },
254: { "ftp://rajanagendra.sun.com:21/test.html?index=21#ref",
255: "ftp://rajanagendra.sun.com:21/test.html?index=21#ref" },
256: {
257: "https://rajanagendra.sun.com:443/test.html?index=21#ref",
258: "https://rajanagendra.sun.com/test.html?index=21#ref" },
259: { "http://rajanagendra.sun.com:80/test.html?index=21#ref",
260: "http://rajanagendra.sun.com/test.html?index=21#ref" },
261:
262: {
263: "file://rajanagendra.sun.com:21/test.html?http://raja.com:0/",
264: "file://rajanagendra.sun.com:21/test.html?http://raja.com:0/" },
265: {
266: "ftp://rajanagendra.sun.com:31/test.html?http://raja.com:21/",
267: "ftp://rajanagendra.sun.com:31/test.html?http://raja.com:21/" },
268: {
269: "https://rajanagendra.sun.com:44/test.html?http://raja.com:443/",
270: "https://rajanagendra.sun.com:44/test.html?http://raja.com:443/" },
271: {
272: "http://rajanagendra.sun.com:98/test.html?http://raja.com:80/",
273: "http://rajanagendra.sun.com:98/test.html?http://raja.com:80/" },
274:
275: { "file://rajanagendra.sun.com:21/test.html?index=21#ref",
276: "file://rajanagendra.sun.com:21/test.html?index=21#ref" },
277: { "ftp://rajanagendra.sun.com:31/test.html?index=21#ref",
278: "ftp://rajanagendra.sun.com:31/test.html?index=21#ref" },
279: { "https://rajanagendra.sun.com:44/test.html?index=21#ref",
280: "https://rajanagendra.sun.com:44/test.html?index=21#ref" },
281: { "http://rajanagendra.sun.com:98/test.html?index=21#ref",
282: "http://rajanagendra.sun.com:98/test.html?index=21#ref" },
283:
284: {
285: " file://rajanagendra.sun.com:0/test.html?index=21#ref",
286: " file://rajanagendra.sun.com:0/test.html?index=21#ref" },
287: {
288: " ftp://rajanagendra.sun.com:21/test.html?index=21#ref",
289: " ftp://rajanagendra.sun.com:21/test.html?index=21#ref" },
290: {
291: " https://rajanagendra.sun.com:443/test.html?index=21#ref",
292: " https://rajanagendra.sun.com/test.html?index=21#ref" },
293: { " http://rajanagendra.sun.com:80/test.html?index=21#ref",
294: " http://rajanagendra.sun.com/test.html?index=21#ref" },
295:
296: { "/test.html", "http://rajanagendra.sun.com/test.html" }, //BugNo:4693657
297: { "../../index.",
298: "http://rajanagendra.sun.com/Base/Raja/../../index." }, //-9
299: { "../", "http://rajanagendra.sun.com/Base/Raja/../" }, //0
300: { "../../", "http://rajanagendra.sun.com/Base/Raja/../../" }, //1
301: { "././", "http://rajanagendra.sun.com/Base/Raja/././" }, //2
302: { "..", "http://rajanagendra.sun.com/Base/Raja/.." }, //3
303: { "../..", "http://rajanagendra.sun.com/Base/Raja/../.." }, //4
304: { "./.", "http://rajanagendra.sun.com/Base/Raja/./." }, //5
305: { "/", "http://rajanagendra.sun.com/" }, //6
306: { "#raj.index", "#raj.index" }, //7
307: { "../../../../functions/javascript.js",
308: "http://rajanagendra.sun.com/Base/Raja/../../../../functions/javascript.js" }, //13
309: { "../../img/background.jpg",
310: "http://rajanagendra.sun.com/Base/Raja/../../img/background.jpg" }, //14
311: { "http://www.sun.com/abc.html",
312: "http://www.sun.com/abc.html" }, //15
313: { "https://www.sun.com/sh.html",
314: "https://www.sun.com/sh.html" }, //16
315: { "https://www.sun.com:78/sh.html",
316: "https://www.sun.com:78/sh.html" }, //17
317: { "htTp://www.sun.com:400/sh.html",
318: "htTp://www.sun.com:400/sh.html" }, //18
319: { "./abc.html",
320: "http://rajanagendra.sun.com/Base/Raja/./abc.html" }, //20
321: { "/abc.html", "http://rajanagendra.sun.com/abc.html" }, //21
322: { "../../abc.html",
323: "http://rajanagendra.sun.com/Base/Raja/../../abc.html" }, //22
324: { "../abc.html",
325: "http://rajanagendra.sun.com/Base/Raja/../abc.html" }, //23
326: { "../abc.html?turn=true",
327: "http://rajanagendra.sun.com/Base/Raja/../abc.html?turn=true" }, //24
328: { "./abc.html?turn=true",
329: "http://rajanagendra.sun.com/Base/Raja/./abc.html?turn=true" }, //25
330: { "htTp://www.sun.com:400/sh.html?roja=ramani",
331: "htTp://www.sun.com:400/sh.html?roja=ramani" }, //26
332: { "./././././abc.html",
333: "http://rajanagendra.sun.com/Base/Raja/./././././abc.html" }, //27
334: { "./raja/mahesh/.././abc.html",
335: "http://rajanagendra.sun.com/Base/Raja/./raja/mahesh/.././abc.html" }, //28
336: { "\t\n/test.html\t",
337: "\t\nhttp://rajanagendra.sun.com/test.html\t" },
338: { "\n/test.html\r",
339: "\nhttp://rajanagendra.sun.com/test.html\r" },
340: { "index.", "http://rajanagendra.sun.com/Base/Raja/index." }, //-10
341: { "abc/index.",
342: "http://rajanagendra.sun.com/Base/Raja/abc/index." }, //-10
343: { "abc/index.html",
344: "http://rajanagendra.sun.com/Base/Raja/abc/index.html" }, //-10
345: { "abc.html",
346: "http://rajanagendra.sun.com/Base/Raja/abc.html" }, //19
347: { "null", "http://rajanagendra.sun.com/Base/Raja/null" }, //30 - Bug4627258
348: { "'null'", "'http://rajanagendra.sun.com/Base/Raja/null'" }, //31 - Bug4627258
349: { "\"/index.html\"",
350: "\"http://rajanagendra.sun.com/index.html\"" }, //29
351: { " ", " " }, //8
352: { " ", " " }, //10
353: { "\"\"", "\"\"" }, //29
354: { "\" \t \t \"", "\" \t \t \"" }, //29
355: //{"user:password@http://sun.com/index.html", "user:password@http://sun.com/index.html"}, //11
356: //{"user:password@./index.html", "user:password@./index.html"}, //12
357: };
358:
359: public TestJSConvertExpressionFunction(String aName) {
360: super (aName);
361: }//constuctor
362:
363: public void testExpression() throws Exception {
364:
365: String functionDef = getDefaultTranslator().getJSFunctionSpec()
366: .getExpressionFunctionDefination(
367: getDefaultTranslator().getPageSpec());
368:
369: for (int i = 0; i < data.length; i++) {
370: try {
371: String result = JScriptInterpreter
372: .exec(
373: functionDef,
374: JSWrapperHelper.CONVERT_EXPRESSION_FUNCTION_NAME,
375: new String[] { data[i][0] });
376: //System.out.println( data[i][0] );
377: assertEquals("Failed at i=" + i + ":" + data[i][0],
378: data[i][1], result);
379: } catch (Exception e) {
380: System.out.println("Failed at i=" + i + data[i][0]);
381: throw e;
382: }
383: }
384: }//testExpression()
385:
386: public void testBug4627258PassingNull() throws Exception {
387: Object[] aArray = { new String[] { null },
388: new Object[] { null }, };
389:
390: String functionDef = getDefaultTranslator().getJSFunctionSpec()
391: .getExpressionFunctionDefination(
392: getDefaultTranslator().getPageSpec());
393:
394: for (int i = 0; i < aArray.length; i++) {
395: Object result = JScriptInterpreter.execObject(functionDef,
396: JSWrapperHelper.CONVERT_EXPRESSION_FUNCTION_NAME,
397: (Object[]) aArray[i]);
398: assertEquals(null, result);
399: }
400: }//testBug4627258PassingNull()
401:
402: public void testBug4627258BehaviorWithFuncPointerArguments()
403: throws Exception {
404: String functionDef = getDefaultTranslator().getJSFunctionSpec()
405: .getExpressionFunctionDefination(
406: getDefaultTranslator().getPageSpec());
407:
408: String[] lFuncNames = { "eval", //std JS Function
409: JSWrapperHelper.CONVERT_EXPRESSION_FUNCTION_NAME, //passs its own func reference
410: "psSplit", };
411:
412: try {
413: for (int i = 0; i < lFuncNames.length; i++) {
414: String testFunctionPointer = "function testFunctionPointer()\n"
415: + "{\n"
416: + " return "
417: + JSWrapperHelper.CONVERT_EXPRESSION_FUNCTION_WRAP_START
418: + lFuncNames[i] + ");\n" + "}\n";
419:
420: String result = JScriptInterpreter.execObject(
421: testFunctionPointer + functionDef,
422: "testFunctionPointer", new String[0])
423: .toString();
424:
425: assertEquals(
426: "When function/object pointer is passed it is not returning the same reference",
427: "org.mozilla.javascript.", result.substring(0,
428: "org.mozilla.javascript.".length()));
429: }
430: } catch (Exception e) {
431: fail("convertFunction Should rewrite only Strings and Not function pointers etc..\n"
432: + StringHelper.exceptionStack2String(e));
433: }
434: }//testBug4627258BehaviorWithFuncPointerArguments()
435:
436: public void testGlobolVarBugNo4791468() throws Exception {
437: String functionDef = "var i=20000;"
438: + "var j=40000;"
439: + getDefaultTranslator().getJSFunctionSpec()
440: .getExpressionFunctionDefination(
441: getDefaultTranslator().getPageSpec())
442: + "\nfunction readVar(aURI)"
443: + "\n{\n"
444: + JSWrapperHelper.CONVERT_EXPRESSION_FUNCTION_WRAP_START
445: + "aURI);\n" + "return i+j;\n" + "}\n";
446:
447: Integer result = (Integer) JScriptInterpreter.execObject(
448: functionDef, "readVar", new String[] { "raja.html" },
449: Integer.class);
450: assertEquals(
451: "If a Gobal Variable i or j is declared, then converfunction is chageing this gobol var",
452: 60000, result.intValue());
453: }//testGlobolVarBugNo4791468()
454:
455: public static void main(String[] args) {
456: RewriterModule.initFile();
457: //BasicTestCase.run( TestJSConvertExpressionFunction.class );
458: TestSuite testSuite = new TestSuite();
459: testSuite.addTest(new TestJSConvertExpressionFunction(
460: "testExpression"));
461: BasicTestCase.run(testSuite);
462: }//main()
463:
464: }//class TestJSConvertExpressionFunction
|