0001: /*
0002: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
0003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
0004: */
0005: package com.sun.portal.rewriter.engines.js.test;
0006:
0007: import com.sun.portal.rewriter.Rewriter;
0008: import com.sun.portal.rewriter.RewriterModule;
0009: import com.sun.portal.rewriter.RewriterPool;
0010: import com.sun.portal.rewriter.engines.LanguageConstants;
0011: import com.sun.portal.rewriter.rom.RuleSet;
0012: import com.sun.portal.rewriter.test.util.BasicTestCase;
0013: import com.sun.portal.rewriter.test.util.CreateRuleSet;
0014: import junit.framework.TestSuite;
0015:
0016: public class TestJSDHTMLVariables extends BasicTestCase {
0017: public TestJSDHTMLVariables(String aName) {
0018: super (aName);
0019: }//constuctor
0020:
0021: public void testSimpleDHTMLVariable() throws Exception {
0022: String[][] lData = {
0023: {
0024: "dhtmlVar = '<a href=\"iPSi18nmatrix.html\" name='iPSi18nmatrix.html'>iPSi18nmatrix.html</a>';",
0025: "dhtmlVar = '<a href=\"http://rajanagendra.sun.com/Base/Raja/iPSi18nmatrix.html\" name='iPSi18nmatrix.html'>iPSi18nmatrix.html</a>';",
0026: "<Attribute name=\"HREF\" />", //html attribute
0027: "<Variable name=\"dhtmlVar\" type=\"DHTML\"/>", //jsvar rule
0028: "" }, //0
0029:
0030: {
0031: //should not translate
0032: "dhtmlVar = '<a href=\"iPSi18nmatrix.html\" name='iPSi18nmatrix.html'>iPSi18nmatrix.html</a>';",
0033: "dhtmlVar = '<a href=\"iPSi18nmatrix.html\" name='iPSi18nmatrix.html'>iPSi18nmatrix.html</a>';",
0034: "", //html attribute
0035: "<Variable name=\"dhtmlVar\" source=\"*rajanagendra.sun.com*\" type=\"DHTML\"/>", //jsvar rule
0036: "" }, //1
0037: };
0038:
0039: for (int i = 0; i < lData.length; i++) {
0040: RuleSet lRuleSet = CreateRuleSet
0041: .withHTMLAttJSVarJSFunRules(lData[i][2],
0042: lData[i][3], "");
0043: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0044: LanguageConstants.JS_MIME);
0045: String lResult = lRewriter.rewrite(lData[i][0],
0046: getDefaultTranslator());
0047: assertEquals("Failed: i = " + i, lData[i][1], lResult);
0048: }//for loop
0049: }//testSimpleDHTMLVariable()
0050:
0051: public void atestDHTMLWithSlash() throws Exception {
0052: String lInput = "var html = '<a href=\"abc.html\"/> '";
0053:
0054: //String lInput =
0055: //"var html = '<a href=\"abc.html\"/> \\\n" + "'\n";
0056: String lExpectation = "var html = '<a href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\"/> \\\n"
0057: + "'\n";
0058:
0059: String lHTMLAttRules = "<Attribute name=\"HREF\" />";
0060: String lJSDHTMLRules = "<Variable name=\"html\" type=\"DHTML\"/>";
0061:
0062: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarJSFunRules(
0063: lHTMLAttRules, lJSDHTMLRules, "");
0064: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0065: LanguageConstants.JS_MIME);
0066: String lResult = lRewriter.rewrite(lInput,
0067: getDefaultJSTranslator());
0068: assertEquals(lExpectation, lResult);
0069: }//testDHTMLWithSlash()
0070:
0071: private static final String input = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
0072: + "<html>\n"
0073: + "<head>\n"
0074: + " <meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\">\n"
0075: + " <meta name=\"author\" content=\"Ajit Sabnis\">\n"
0076: + "\n"
0077: + " <title>/nested/25k/addressBook</title>\n"
0078: + "\n"
0079: + " <script>\n"
0080: + "// Utility Functions\n"
0081: + "function displayError(errorURL, errorMessage) {\n"
0082: + " open(errorURL + '?' + errorMessage)\n"
0083: + "}\n"
0084: + "\n"
0085: + "function validateName(name) {\n"
0086: + " error = false\n"
0087: + " errorMessage = null\n"
0088: + " \n"
0089: + " if (name.length == 0) {\n"
0090: + " error = true\n"
0091: + " errorMessage = 'Name cannot be empty. Please enter valid name.'\n"
0092: + " }\n"
0093: + " \n"
0094: + " return errorMessage\n"
0095: + "}\n"
0096: + "\n"
0097: + "function validateZip(zip) {\n"
0098: + " error = false\n"
0099: + " errorMessage = null\n"
0100: + " \n"
0101: + " if (zip.length != 6) {\n"
0102: + " error = true\n"
0103: + " errorMessage = 'Zip code should be 6 digits long. Please enter valid zip.'\n"
0104: + " }\n"
0105: + " \n"
0106: + " return errorMessage\n"
0107: + "}\n"
0108: + "\n"
0109: + "// Basic Event Handlers\n"
0110: + "function eventHandler() {\n"
0111: + " alert('Got' + event.type + 'event!')\n"
0112: + "}\n"
0113: + "\n"
0114: + "function clickHandler(clickURL) {\n"
0115: + " alert(clickURL)\n"
0116: + "}\n"
0117: + "\n"
0118: + "// Add\n"
0119: + "function addSubmitHandler(form) {\n"
0120: + " result = true\n"
0121: + " errorURL = '/nested/25k/error.html'\n"
0122: + " \n"
0123: + " // Validate name\n"
0124: + " errorMessage = validateName(form.abName.value)\n"
0125: + " if (errorMessage != null)\n"
0126: + " result = false\n"
0127: + " \n"
0128: + " // Validate address line 1\n"
0129: + " if (result == true) {\n"
0130: + " }\n"
0131: + " \n"
0132: + " // Validate address line 2\n"
0133: + " if (result == true) {\n"
0134: + " }\n"
0135: + " \n"
0136: + " // Validate city\n"
0137: + " if (result == true) {\n"
0138: + " }\n"
0139: + " \n"
0140: + " // Validate zip\n"
0141: + " if (result == true) {\n"
0142: + " errorMessage = validateZip(form.abZip.value)\n"
0143: + " if (errorMessage != null)\n"
0144: + " result = false\n"
0145: + " }\n"
0146: + "\n"
0147: + " // Check for error\n"
0148: + " if (result == false) {\n"
0149: + " displayError(errorURL, errorMessage) \n"
0150: + " }\n"
0151: + " \n"
0152: + " return result\n"
0153: + "}\n"
0154: + "\n"
0155: + "// View\n"
0156: + "function viewSubmitHandler(form) {\n"
0157: + " result = true\n"
0158: + " errorURL = '/nested/25k/error.html'\n"
0159: + " \n"
0160: + " // Validate name\n"
0161: + " errorMessage = validateName(form.abName.value)\n"
0162: + " if (errorMessage != null)\n"
0163: + " result = false\n"
0164: + " \n"
0165: + " // Check for error\n"
0166: + " if (result == false) {\n"
0167: + " displayError(errorURL, errorMessage) \n"
0168: + " }\n"
0169: + " \n"
0170: + " return result\n"
0171: + "}\n"
0172: + "\n"
0173: + "// Change\n"
0174: + "function changeSubmitHandler(form) {\n"
0175: + " result = true\n"
0176: + " errorURL = '/nested/25k/error.html'\n"
0177: + " \n"
0178: + " // Validate name\n"
0179: + " errorMessage = validateName(form.abName.value)\n"
0180: + " if (errorMessage != null)\n"
0181: + " result = false\n"
0182: + " \n"
0183: + " // Check for error\n"
0184: + " if (result == false) {\n"
0185: + " displayError(errorURL, errorMessage) \n"
0186: + " }\n"
0187: + " \n"
0188: + " return result\n"
0189: + "}\n"
0190: + "\n"
0191: + "// Delete\n"
0192: + "function deleteSubmitHandler(form) {\n"
0193: + " result = true\n"
0194: + " errorURL = '/nested/25k/error.html'\n"
0195: + " \n"
0196: + " // Validate name\n"
0197: + " errorMessage = validateName(form.abName.value)\n"
0198: + " if (errorMessage != null)\n"
0199: + " result = false\n"
0200: + " \n"
0201: + " // Check for error\n"
0202: + " if (result == false) {\n"
0203: + " displayError(errorURL, errorMessage) \n"
0204: + " }\n"
0205: + " \n"
0206: + " return result\n"
0207: + "}\n"
0208: + "\n"
0209: + "// Dummy\n"
0210: + "function dummy() {\n"
0211: + " // 5 Dummy rewriter targets\n"
0212: + " errorURL = '/nested/25k/error.html'\n"
0213: + " errorURL = '/nested/25k/error.html'\n"
0214: + " errorURL = '/nested/25k/error.html'\n"
0215: + " errorURL = '/nested/25k/error.html'\n"
0216: + " errorURL = '/nested/25k/error.html'\n"
0217: + "\n"
0218: + " // 10 alerts\n"
0219: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0220: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0221: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0222: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0223: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0224: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0225: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0226: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0227: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0228: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0229: + " // 10 such alert rows => 1000 bytes\n"
0230: + " \n"
0231: + " // 10 alerts\n"
0232: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0233: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0234: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0235: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0236: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0237: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0238: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0239: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0240: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0241: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0242: + " // 10 such alert rows => 1000 bytes\n"
0243: + " \n"
0244: + " // 10 alerts\n"
0245: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0246: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0247: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0248: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0249: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0250: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0251: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0252: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0253: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0254: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0255: + " // 10 such alert rows => 1000 bytes\n"
0256: + " \n"
0257: + " // 10 alerts\n"
0258: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0259: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0260: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0261: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0262: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0263: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0264: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0265: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0266: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0267: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0268: + " // 10 such alert rows => 1000 bytes\n"
0269: + " \n"
0270: + " // 10 alerts\n"
0271: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0272: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0273: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0274: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0275: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0276: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0277: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0278: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0279: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0280: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0281: + " // 10 such alert rows => 1000 bytes\n"
0282: + " \n"
0283: + " // 10 alerts\n"
0284: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0285: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0286: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0287: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0288: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0289: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0290: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0291: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0292: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0293: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0294: + " // 10 such alert rows => 1000 bytes\n"
0295: + " \n"
0296: + " // 10 alerts\n"
0297: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0298: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0299: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0300: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0301: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0302: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0303: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0304: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0305: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0306: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0307: + " // 10 such alert rows => 1000 bytes\n"
0308: + " \n"
0309: + " // 10 alerts\n"
0310: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0311: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0312: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0313: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0314: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0315: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0316: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0317: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0318: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0319: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0320: + " // 10 such alert rows => 1000 bytes\n"
0321: + " \n"
0322: + " // 10 alerts\n"
0323: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0324: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0325: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0326: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0327: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0328: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0329: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0330: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0331: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0332: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0333: + " // 10 such alert rows => 1000 bytes\n"
0334: + " \n"
0335: + " // 10 alerts\n"
0336: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0337: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0338: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0339: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0340: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0341: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0342: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0343: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0344: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0345: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0346: + " // 10 such alert rows => 1000 bytes\n"
0347: + " \n"
0348: + " // 10 alerts\n"
0349: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0350: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0351: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0352: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0353: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0354: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0355: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0356: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0357: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0358: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0359: + " // 10 such alert rows => 1000 bytes\n"
0360: + " \n"
0361: + " // 10 alerts\n"
0362: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0363: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0364: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0365: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0366: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0367: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0368: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0369: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0370: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0371: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0372: + " // 10 such alert rows => 1000 bytes\n"
0373: + " \n"
0374: + " // 10 alerts\n"
0375: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0376: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0377: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0378: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0379: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0380: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0381: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0382: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0383: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0384: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0385: + " // 10 such alert rows => 1000 bytes\n"
0386: + " \n"
0387: + " // 10 alerts\n"
0388: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0389: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0390: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0391: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0392: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0393: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0394: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0395: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0396: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0397: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0398: + " // 10 such alert rows => 1000 bytes\n"
0399: + " \n"
0400: + " // 10 alerts\n"
0401: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0402: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0403: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0404: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0405: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0406: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0407: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0408: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0409: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0410: + " alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789');alert('0123456789')\n"
0411: + " // 10 such alert rows => 1000 bytes\n"
0412: + " \n"
0413: + " // 15KB JS Content\n"
0414: + "\n"
0415: + " // 5 Dummy rewriter targets\n"
0416: + " errorURL = '/nested/25k/error.html'\n"
0417: + " errorURL = '/nested/25k/error.html'\n"
0418: + " errorURL = '/nested/25k/error.html'\n"
0419: + " errorURL = '/nested/25k/error.html'\n"
0420: + " errorURL = '/nested/25k/error.html'\n"
0421: + "}\n"
0422: + "\n"
0423: + " </script>\n"
0424: + "</head>\n"
0425: + "\n"
0426: + "<body>\n"
0427: + "\n"
0428: + "<!-- Create the HTML page now: JS Variable html below has about 62 lines. -->\n"
0429: + "<script>\n"
0430: + "var html =\n"
0431: + "'\\\n"
0432: + "<table cellpadding=\"2\" cellspacing=\"2\" border=\"1\" width=\"100%\"> \\\n"
0433: + " <caption><b>Address Book</b></caption> \\\n"
0434: + " \\\n"
0435: + " <tbody> \\\n"
0436: + " <tr><td> \\\n"
0437: + " <table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\"> \\\n"
0438: + "'\n"
0439: + "\n"
0440: + "html +=\n"
0441: + "'\\\n"
0442: + " <caption><b>Menu</b></caption> \\\n"
0443: + " \\\n"
0444: + " <tbody> \\\n"
0445: + " <tr> \\\n"
0446: + " <td><a href=\"/nested/25k/add.html\" onClick=\"hrefURL=\\'/nested/25k/add.html\\';clickHandler(hrefURL)\">New Entry</a></td> \\\n"
0447: + " <td><a href=\"/nested/25k/view.html\" onClick=\"hrefURL=\\'/nested/25k/view.html\\';clickHandler(hrefURL)\">View Entry</a></td> \\\n"
0448: + " <td><a href=\"/nested/25k/change.html\" onClick=\"clickHandler(\\'/nested/25k/change.html\\')\">Change Entry</a></td> \\\n"
0449: + "'\n"
0450: + "\n"
0451: + "html +=\n"
0452: + "'\\\n"
0453: + " <td><a href=\"/nested/25k/delete.html\" onClick=\"clickHandler(\\'/nested/25k/delete.html\\')\">Delete Entry</a></td> \\\n"
0454: + " <td><a href=\"/nested/25k/help.html\" onClick=\"clickHandler(this.href)\">Help</a></td> \\\n"
0455: + " </tr> \\\n"
0456: + " </tbody> \\\n"
0457: + " </table> \\\n"
0458: + " </td></tr> \\\n"
0459: + " \\\n"
0460: + "'\n"
0461: + "\n"
0462: + "html +=\n"
0463: + "'\\\n"
0464: + " <tr><td> \\\n"
0465: + " <form name=\"add\" method=\"get\" action=\"/nested/25k/addHandler.html\" \\\n"
0466: + " onSubmit=\"return addSubmitHandler(this)\"> \\\n"
0467: + " <table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\"> \\\n"
0468: + " <caption><b>Add New Entry in Address Book</b></caption> \\\n"
0469: + " \\\n"
0470: + "'\n"
0471: + "\n"
0472: + "html +=\n"
0473: + "'\\\n"
0474: + " <tbody> \\\n"
0475: + " <tr> \\\n"
0476: + " <td align=\"right\"><label>Name</label></td> \\\n"
0477: + " <td><input type=\"text\" name=\"abName\" size=\"50\"></td> \\\n"
0478: + " </tr> \\\n"
0479: + " \\\n"
0480: + " <tr> \\\n"
0481: + "'\n"
0482: + "\n"
0483: + "html +=\n"
0484: + "'\\\n"
0485: + " <td align=\"right\"><label>Address Line 1</label></td> \\\n"
0486: + " <td><input type=\"text\" name=\"abAddressLine1\" size=\"50\"></td> \\\n"
0487: + " </tr> \\\n"
0488: + " \\\n"
0489: + " <tr> \\\n"
0490: + " <td align=\"right\"><label>Address Line 2</label></td> \\\n"
0491: + " <td><input type=\"text\" name=\"abAddressLine2\" size=\"50\"></td> \\\n"
0492: + "'\n"
0493: + "\n"
0494: + "html +=\n"
0495: + "'\\\n"
0496: + " </tr> \\\n"
0497: + " \\\n"
0498: + " <tr> \\\n"
0499: + " <td align=\"right\"><label>City</label></td> \\\n"
0500: + " <td><input type=\"text\" name=\"abCity\" size=\"50\"></td> \\\n"
0501: + " </tr> \\\n"
0502: + " \\\n"
0503: + "'\n"
0504: + "\n"
0505: + "html +=\n"
0506: + "'\\\n"
0507: + " <tr> \\\n"
0508: + " <td align=\"right\"><label>Zip</label></td> \\\n"
0509: + " <td><input type=\"text\" name=\"abZip\" size=\"50\"></td> \\\n"
0510: + " </tr> \\\n"
0511: + " \\\n"
0512: + " <tr> \\\n"
0513: + " <td align=\"right\"><input type=\"submit\" name=\"submit\" value=\"submit\"></td> \\\n"
0514: + "'\n"
0515: + "\n"
0516: + "html +=\n"
0517: + "'\\\n"
0518: + " <td><input type=\"reset\" name=\"reset\" value=\"reset\"></td> \\\n"
0519: + " </tr> \\\n"
0520: + " </tbody> \\\n"
0521: + " </table> \\\n"
0522: + " </form> \\\n"
0523: + " </td></tr> \\\n"
0524: + " </tbody> \\\n"
0525: + "</table> \\\n"
0526: + "'\n"
0527: + "\n"
0528: + "document.write(html)\n"
0529: + "</script>\n"
0530: + " \n" + "</body>\n" + "</html>\n";
0531:
0532: public void testPerfBug1() throws Exception {
0533: String lExpectation = input;
0534:
0535: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarJSFunRules("",
0536: "", "");
0537: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0538: LanguageConstants.HTML_MIME);
0539: String lResult = lRewriter.rewrite(input,
0540: getDefaultTranslator());
0541: assertEquals(lExpectation, lResult);
0542: }//testPerfBug1()
0543:
0544: public void testPerfBug() throws Exception {
0545: String lInput = "var html = '\\"
0546: + "<table cellpadding=\"2\" cellspacing=\"2\" border=\"1\" width=\"100%\"> \\\n"
0547: + " <caption><b>Address Book</b></caption> \\\n"
0548: + " \\\n"
0549: + " <tbody> \\\n"
0550: + " <tr> \\\n"
0551: + " <td align=\"right\"><input type=\"submit\" name=\"submit\" value=\"submit\"></td> \\\n"
0552: + " <td><input type=\"reset\" name=\"reset\" value=\"reset\"></td> \\\n"
0553: + " </tr> \\\n" + " </tbody> \\\n"
0554: + " </table> \\\n" + " </form> \\\n"
0555: + " </td></tr> \\\n" + " </tbody> \\\n"
0556: + "</table> '\n" + "document.write(html) \n";
0557:
0558: String lExpectation = lInput;
0559:
0560: RuleSet lRuleSet = CreateRuleSet.emptyRuleSet();
0561: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0562: LanguageConstants.JS_MIME);
0563: String lResult = lRewriter.rewrite(lInput,
0564: getDefaultJSTranslator());
0565: assertEquals(lExpectation, lResult);
0566: }//testPerfBug()
0567:
0568: public void testPlusEqualDHTMLNoRules() throws Exception {
0569: String lInput = "<script>\n"
0570: + "var html = '<table cellpadding=\"2\" cellspacing=\"2\" border=\"1\" width=\"100%\"><caption><b>Address Book</b></caption><tbody><tr><td><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\">'\n"
0571: + "html += '<caption><b>Menu</b></caption><tbody><tr><td><a href=\"/nested/25k/add.html\">New Entry</a></td><td><a href=\"/nested/25k/view.html\">View Entry</a></td><td><a href=\"/nested/25k/change.html\">Change Entry</a></td>'\n"
0572: + "html += '<td><a href=\"/nested/25k/delete.html\">Delete Entry</a></td><td><a href=\"/nested/25k/help.html\">Help</a></td></tr></tbody></table></td></tr>'\n"
0573: + "html += '<tr><td><form name=\"add\" method=\"get\" action=\"/nested/25k/addHandler.html\" onSubmit=\"return addSubmitHandler(this)\"><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\"><caption><b>Add New Entry in Address Book</b></caption>'\n"
0574: + "html += '<tbody><tr><td align=\"right\"><label>Name</label></td><td><input type=\"text\" name=\"abName\" size=\"50\"></td></tr><tr>'\n"
0575: + "html += '<td align=\"right\"><label>Address Line 1</label></td><td><input type=\"text\" name=\"abAddressLine1\" size=\"50\"></td></tr><tr><td align=\"right\"><label>Address Line 2</label></td><td><input type=\"text\" name=\"abAddressLine2\" size=\"50\"></td>'\n"
0576: + "html += '</tr><tr><td align=\"right\"><label>City</label></td><td><input type=\"text\" name=\"abCity\" size=\"50\"></td></tr>'\n"
0577: + "html += '<tr><td align=\"right\"><label>Zip</label></td><td><input type=\"text\" name=\"abZip\" size=\"50\"></td></tr><tr><td align=\"right\"><input type=\"submit\" name=\"submit\" value=\"submit\"></td>'\n"
0578: + "html += '<td><input type=\"reset\" name=\"reset\" value=\"reset\"></td></tr></tbody></table></form></td></tr></tbody></table>'\n"
0579: + "\n" + "document.write(html)\n" + "</script>\n";
0580:
0581: String lExpectation = lInput;
0582:
0583: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarJSFunRules("",
0584: "", "");
0585: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0586: LanguageConstants.HTML_MIME);
0587: String lResult = lRewriter.rewrite(lInput,
0588: getDefaultTranslator());
0589: assertEquals(lExpectation, lResult);
0590: }//testPlusEqualDHTMLNoRules()
0591:
0592: public void testPlusEqualDHTMLWithRules() throws Exception {
0593: String lInput = "<script>\n"
0594: + "var html = '<table cellpadding=\"2\" cellspacing=\"2\" border=\"1\" width=\"100%\"><caption><b>Address Book</b></caption><tbody><tr><td><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\">'\n"
0595: + "html += '<caption><b>Menu</b></caption><tbody><tr><td><a href=\"/nested/25k/add.html\">New Entry</a></td><td><a href=\"/nested/25k/view.html\">View Entry</a></td><td><a href=\"/nested/25k/change.html\">Change Entry</a></td>'\n"
0596: + "html += '<td><a href=\"/nested/25k/delete.html\">Delete Entry</a></td><td><a href=\"/nested/25k/help.html\">Help</a></td></tr></tbody></table></td></tr>'\n"
0597: + "html += '<tr><td><form name=\"add\" method=\"get\" action=\"/nested/25k/addHandler.html\" onSubmit=\"return addSubmitHandler(this)\"><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\"><caption><b>Add New Entry in Address Book</b></caption>'\n"
0598: + "html += '<tbody><tr><td align=\"right\"><label>Name</label></td><td><input type=\"text\" name=\"abName\" size=\"50\"></td></tr><tr>'\n"
0599: + "html += '<td align=\"right\"><label>Address Line 1</label></td><td><input type=\"text\" name=\"abAddressLine1\" size=\"50\"></td></tr><tr><td align=\"right\"><label>Address Line 2</label></td><td><input type=\"text\" name=\"abAddressLine2\" size=\"50\"></td>'\n"
0600: + "html += '</tr><tr><td align=\"right\"><label>City</label></td><td><input type=\"text\" name=\"abCity\" size=\"50\"></td></tr>'\n"
0601: + "html += '<tr><td align=\"right\"><label>Zip</label></td><td><input type=\"text\" name=\"abZip\" size=\"50\"></td></tr><tr><td align=\"right\"><input type=\"submit\" name=\"submit\" value=\"submit\"></td>'\n"
0602: + "html += '<td><input type=\"reset\" name=\"reset\" value=\"reset\"></td></tr></tbody></table></form></td></tr></tbody></table>'\n"
0603: + "\n" + "document.write(html)\n" + "</script>\n";
0604:
0605: String lExpectation = "<script>\n"
0606: + "var html = '<table cellpadding=\"2\" cellspacing=\"2\" border=\"1\" width=\"100%\"><caption><b>Address Book</b></caption><tbody><tr><td><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\">'\n"
0607: + "html += '<caption><b>Menu</b></caption><tbody><tr><td><a href=\"http://rajanagendra.sun.com/nested/25k/add.html\">New Entry</a></td><td><a href=\"http://rajanagendra.sun.com/nested/25k/view.html\">View Entry</a></td><td><a href=\"http://rajanagendra.sun.com/nested/25k/change.html\">Change Entry</a></td>'\n"
0608: + "html += '<td><a href=\"http://rajanagendra.sun.com/nested/25k/delete.html\">Delete Entry</a></td><td><a href=\"http://rajanagendra.sun.com/nested/25k/help.html\">Help</a></td></tr></tbody></table></td></tr>'\n"
0609: + "html += '<tr><td><form name=\"add\" method=\"get\" action=\"/nested/25k/addHandler.html\" onSubmit=\"return addSubmitHandler(this)\"><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\"><caption><b>Add New Entry in Address Book</b></caption>'\n"
0610: + "html += '<tbody><tr><td align=\"right\"><label>Name</label></td><td><input type=\"text\" name=\"abName\" size=\"50\"></td></tr><tr>'\n"
0611: + "html += '<td align=\"right\"><label>Address Line 1</label></td><td><input type=\"text\" name=\"abAddressLine1\" size=\"50\"></td></tr><tr><td align=\"right\"><label>Address Line 2</label></td><td><input type=\"text\" name=\"abAddressLine2\" size=\"50\"></td>'\n"
0612: + "html += '</tr><tr><td align=\"right\"><label>City</label></td><td><input type=\"text\" name=\"abCity\" size=\"50\"></td></tr>'\n"
0613: + "html += '<tr><td align=\"right\"><label>Zip</label></td><td><input type=\"text\" name=\"abZip\" size=\"50\"></td></tr><tr><td align=\"right\"><input type=\"submit\" name=\"submit\" value=\"submit\"></td>'\n"
0614: + "html += '<td><input type=\"reset\" name=\"reset\" value=\"reset\"></td></tr></tbody></table></form></td></tr></tbody></table>'\n"
0615: + "\n" + "document.write(html)\n" + "</script>\n";
0616:
0617: String lHTMLAttRules = "<Attribute name=\"HREF\" />";
0618: String lJSDHTMLVarRules = "<Variable name=\"html\" source=\"*rajanagendra.sun.com*\" type=\"DHTML\"/>";
0619:
0620: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarJSFunRules(
0621: lHTMLAttRules, lJSDHTMLVarRules, "");
0622: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0623: LanguageConstants.HTML_MIME);
0624: String lResult = lRewriter.rewrite(lInput,
0625: getDefaultTranslator());
0626: assertEquals(lExpectation, lResult);
0627: }//testPlusEqualDHTMLWithRules()
0628:
0629: public void testPlusEqualDHTMLVarientNoRules() throws Exception {
0630: String lInput = "<script>\n"
0631: + "var html = '<table cellpadding=\"2\" cellspacing=\"2\" border=\"1\" width=\"100%\"><caption><b>Address Book</b></caption><tbody><tr><td><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\">'\n"
0632: + "html = html + '<caption><b>Menu</b></caption><tbody><tr><td><a href=\"/nested/25k/add.html\">New Entry</a></td><td><a href=\"/nested/25k/view.html\">View Entry</a></td><td><a href=\"/nested/25k/change.html\">Change Entry</a></td>'\n"
0633: + "html = html + '<td><a href=\"/nested/25k/delete.html\">Delete Entry</a></td><td><a href=\"/nested/25k/help.html\">Help</a></td></tr></tbody></table></td></tr>'\n"
0634: + "html = html + '<tr><td><form name=\"add\" method=\"get\" action=\"/nested/25k/addHandler.html\" onSubmit=\"return addSubmitHandler(this)\"><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\"><caption><b>Add New Entry in Address Book</b></caption>'\n"
0635: + "html = html + '<tbody><tr><td align=\"right\"><label>Name</label></td><td><input type=\"text\" name=\"abName\" size=\"50\"></td></tr><tr>'\n"
0636: + "html = html + '<td align=\"right\"><label>Address Line 1</label></td><td><input type=\"text\" name=\"abAddressLine1\" size=\"50\"></td></tr><tr><td align=\"right\"><label>Address Line 2</label></td><td><input type=\"text\" name=\"abAddressLine2\" size=\"50\"></td>'\n"
0637: + "html = html + '</tr><tr><td align=\"right\"><label>City</label></td><td><input type=\"text\" name=\"abCity\" size=\"50\"></td></tr>'\n"
0638: + "html = html + '<tr><td align=\"right\"><label>Zip</label></td><td><input type=\"text\" name=\"abZip\" size=\"50\"></td></tr><tr><td align=\"right\"><input type=\"submit\" name=\"submit\" value=\"submit\"></td>'\n"
0639: + "html = html + '<td><input type=\"reset\" name=\"reset\" value=\"reset\"></td></tr></tbody></table></form></td></tr></tbody></table>'\n"
0640: + "\n" + "document.write(html)\n" + "</script>\n";
0641: String lExpectation = lInput;
0642:
0643: RuleSet lRuleSet = CreateRuleSet.emptyRuleSet();
0644: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0645: LanguageConstants.HTML_MIME);
0646: String lResult = lRewriter.rewrite(lInput,
0647: getDefaultTranslator());
0648: assertEquals(lExpectation, lResult);
0649: }//testPlusEqualDHTMLVarientNoRules()
0650:
0651: public void testPlusEqualDHTMLVarientWithRules() throws Exception {
0652: String lInput = "<script>\n"
0653: + "var html = '<table cellpadding=\"2\" cellspacing=\"2\" border=\"1\" width=\"100%\"><caption><b>Address Book</b></caption><tbody><tr><td><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\">'\n"
0654: + "html = html + '<caption><b>Menu</b></caption><tbody><tr><td><a href=\"/nested/25k/add.html\">New Entry</a></td><td><a href=\"/nested/25k/view.html\">View Entry</a></td><td><a href=\"/nested/25k/change.html\">Change Entry</a></td>'\n"
0655: + "html = html + '<td><a href=\"/nested/25k/delete.html\">Delete Entry</a></td><td><a href=\"/nested/25k/help.html\">Help</a></td></tr></tbody></table></td></tr>'\n"
0656: + "html = html + '<tr><td><form name=\"add\" method=\"get\" action=\"/nested/25k/addHandler.html\" onSubmit=\"return addSubmitHandler(this)\"><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\"><caption><b>Add New Entry in Address Book</b></caption>'\n"
0657: + "html = html + '<tbody><tr><td align=\"right\"><label>Name</label></td><td><input type=\"text\" name=\"abName\" size=\"50\"></td></tr><tr>'\n"
0658: + "html = html + '<td align=\"right\"><label>Address Line 1</label></td><td><input type=\"text\" name=\"abAddressLine1\" size=\"50\"></td></tr><tr><td align=\"right\"><label>Address Line 2</label></td><td><input type=\"text\" name=\"abAddressLine2\" size=\"50\"></td>'\n"
0659: + "html = html + '</tr><tr><td align=\"right\"><label>City</label></td><td><input type=\"text\" name=\"abCity\" size=\"50\"></td></tr>'\n"
0660: + "html = html + '<tr><td align=\"right\"><label>Zip</label></td><td><input type=\"text\" name=\"abZip\" size=\"50\"></td></tr><tr><td align=\"right\"><input type=\"submit\" name=\"submit\" value=\"submit\"></td>'\n"
0661: + "html = html + '<td><input type=\"reset\" name=\"reset\" value=\"reset\"></td></tr></tbody></table></form></td></tr></tbody></table>'\n"
0662: + "\n" + "document.write(html)\n" + "</script>\n";
0663:
0664: String lExpectation = "<script>\n"
0665: + "var html = '<table cellpadding=\"2\" cellspacing=\"2\" border=\"1\" width=\"100%\"><caption><b>Address Book</b></caption><tbody><tr><td><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\">'\n"
0666: + "html = html + '<caption><b>Menu</b></caption><tbody><tr><td><a href=\"http://rajanagendra.sun.com/nested/25k/add.html\">New Entry</a></td><td><a href=\"http://rajanagendra.sun.com/nested/25k/view.html\">View Entry</a></td><td><a href=\"http://rajanagendra.sun.com/nested/25k/change.html\">Change Entry</a></td>'\n"
0667: + "html = html + '<td><a href=\"http://rajanagendra.sun.com/nested/25k/delete.html\">Delete Entry</a></td><td><a href=\"http://rajanagendra.sun.com/nested/25k/help.html\">Help</a></td></tr></tbody></table></td></tr>'\n"
0668: + "html = html + '<tr><td><form name=\"add\" method=\"get\" action=\"/nested/25k/addHandler.html\" onSubmit=\"return addSubmitHandler(this)\"><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\"><caption><b>Add New Entry in Address Book</b></caption>'\n"
0669: + "html = html + '<tbody><tr><td align=\"right\"><label>Name</label></td><td><input type=\"text\" name=\"abName\" size=\"50\"></td></tr><tr>'\n"
0670: + "html = html + '<td align=\"right\"><label>Address Line 1</label></td><td><input type=\"text\" name=\"abAddressLine1\" size=\"50\"></td></tr><tr><td align=\"right\"><label>Address Line 2</label></td><td><input type=\"text\" name=\"abAddressLine2\" size=\"50\"></td>'\n"
0671: + "html = html + '</tr><tr><td align=\"right\"><label>City</label></td><td><input type=\"text\" name=\"abCity\" size=\"50\"></td></tr>'\n"
0672: + "html = html + '<tr><td align=\"right\"><label>Zip</label></td><td><input type=\"text\" name=\"abZip\" size=\"50\"></td></tr><tr><td align=\"right\"><input type=\"submit\" name=\"submit\" value=\"submit\"></td>'\n"
0673: + "html = html + '<td><input type=\"reset\" name=\"reset\" value=\"reset\"></td></tr></tbody></table></form></td></tr></tbody></table>'\n"
0674: + "\n" + "document.write(html)\n" + "</script>\n";
0675:
0676: String lHTMLAttRules = "<Attribute name=\"HREF\" />";
0677: String lJSDHTMLVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
0678:
0679: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarJSFunRules(
0680: lHTMLAttRules, lJSDHTMLVarRules, "");
0681: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0682: LanguageConstants.HTML_MIME);
0683: String lResult = lRewriter.rewrite(lInput,
0684: getDefaultTranslator());
0685: assertEquals(lExpectation, lResult);
0686: }//testPlusEqualDHTMLVarientWithRules()
0687:
0688: public void testSamsungDHTMLVariables() throws Exception {
0689: String lInput = "var tempDhtml = \"<a href='index.html'>go naver</a>\";\n"
0690: + "var JavaDhtml = tempDhtml;\n";
0691:
0692: String lExpectation = "var tempDhtml = \"<a href='http://rajanagendra.sun.com/Base/Raja/index.html'>go naver</a>\";\n"
0693: + "var JavaDhtml = tempDhtml;\n";
0694:
0695: String lHTMLAttRules = "<Attribute name=\"HREF\" />";
0696: String lJSVarRules = "<Variable name=\"tempDhtml\" type=\"DHTML\" source=\"*rajanagendra.sun.com*\"/>";
0697:
0698: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarJSFunRules(
0699: lHTMLAttRules, lJSVarRules, "");
0700: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0701: LanguageConstants.JS_MIME);
0702: String lResult = lRewriter.rewrite(lInput,
0703: getDefaultTranslator());
0704: assertEquals(lExpectation, lResult);
0705: }//testSamsungDHTMLVariables()
0706:
0707: public void testSamsungDHTMLVariablesInvalidRule() throws Exception {
0708: String lInput = "var tempDhtml = \"<a href='../ind'>go naver</a>\";\n"
0709: + "var JavaDhtml = tempDhtml;\n";
0710:
0711: String lExpectation = "var tempDhtml = \"<a href='../ind'>go naver</a>\";\n"
0712: + "var JavaDhtml = tempDhtml;\n";
0713:
0714: String lHTMLAttRules = "<Attribute name=\"HREF\" />";
0715: String lJSVarRules = "<Variable name=\"JavaDhtml\" type=\"DHTML\"/>";
0716:
0717: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarJSFunRules(
0718: lHTMLAttRules, lJSVarRules, "");
0719:
0720: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0721: LanguageConstants.JS_MIME);
0722: String lResult = lRewriter.rewrite(lInput,
0723: getDefaultTranslator());
0724: assertEquals(lExpectation, lResult);
0725: }//testSamsungDHTMLVariablesInvalidRule()
0726:
0727: public void testBugNo4494740() throws Exception {
0728: String lInput = "<script> \n"
0729: + "var BodyHtml= '\\\\n<P>\\\\n<IFRAME SRC=\"/mail01/ml12345.nsf/38d46bf5e8f08834852564b500129b2c/5fad94b07273563f85256a a0000e4ea9/Body/M2?OpenElement\" CLASS=\"s-form-bodyiframe\">\\\\n\\\\n<P>\\\\n<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=4>\\\\n<TR VALIGN=middle><TD><A HREF=\"/mail01/ml12345.nsf/38d46bf5e8f08834852564b500129b2c/5fad94b07273563f85256 aa0000e4ea9/Body/M2?OpenElement\"><IMG SRC=\"/icons/medoc.gif\" BORDER=0 HSPACE=4 ALIGN=middle></A></TD><TD>text/html</TD></TR>\\n</TABLE>\\n</IFRAME>\\n';\n"
0730: + "</script>\n";
0731:
0732: String lExpectation = "<script> \n"
0733: + "var BodyHtml= '\\\\n<P>\\\\n<IFRAME SRC=\"http://rajanagendra.sun.com/mail01/ml12345.nsf/38d46bf5e8f08834852564b500129b2c/5fad94b07273563f85256a a0000e4ea9/Body/M2?OpenElement\" CLASS=\"s-form-bodyiframe\">\\\\n\\\\n<P>\\\\n<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=4>\\\\n<TR VALIGN=middle><TD><A HREF=\"/mail01/ml12345.nsf/38d46bf5e8f08834852564b500129b2c/5fad94b07273563f85256 aa0000e4ea9/Body/M2?OpenElement\"><IMG SRC=\"http://rajanagendra.sun.com/icons/medoc.gif\" BORDER=0 HSPACE=4 ALIGN=middle></A></TD><TD>text/html</TD></TR>\\n</TABLE>\\n</IFRAME>\\n';\n"
0734: + "</script>\n";
0735:
0736: String lHTMLAttRules = "<Attribute name=\"sRC\" />";
0737: String lJSVarRules = "<Variable name=\"BodyHtml\" source=\"*sun.*\" type=\"DHTML\"/>";
0738:
0739: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarJSFunRules(
0740: lHTMLAttRules, lJSVarRules, "");
0741:
0742: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0743: LanguageConstants.HTML_MIME);
0744: String lResult = lRewriter.rewrite(lInput,
0745: getDefaultTranslator());
0746: assertEquals(lExpectation, lResult);
0747: }//testBugNo4494740()
0748:
0749: public void testBugNo4494740Varient() throws Exception {
0750: String lInput = "<script> \n"
0751: + "var BodyHtml= '<P>\\\\n<IFRAME SRC=\"/mail01/ml12345.nsf/38d46bf5e8f08834852564b500129b2c/5fad94b07273563f85256a a0000e4ea9/Body/M2?OpenElement\" CLASS=\"s-form-bodyiframe\">\\\\n\\\\n<P>\\\\n<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=4>\\\\n<TR VALIGN=middle><TD><A HREF=\"/mail01/ml12345.nsf/38d46bf5e8f08834852564b500129b2c/5fad94b07273563f85256 aa0000e4ea9/Body/M2?OpenElement\"><IMG SRC=\"/icons/medoc.gif\" BORDER=0 HSPACE=4 ALIGN=middle></A></TD><TD>text/html</TD></TR>\\n</TABLE>\\n</IFRAME>\\n';\n"
0752: + "</script>\n";
0753:
0754: String lExpectation = "<script> \n"
0755: + "var BodyHtml= '<P>\\\\n<IFRAME SRC=\"http://rajanagendra.sun.com/mail01/ml12345.nsf/38d46bf5e8f08834852564b500129b2c/5fad94b07273563f85256a a0000e4ea9/Body/M2?OpenElement\" CLASS=\"s-form-bodyiframe\">\\\\n\\\\n<P>\\\\n<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=4>\\\\n<TR VALIGN=middle><TD><A HREF=\"/mail01/ml12345.nsf/38d46bf5e8f08834852564b500129b2c/5fad94b07273563f85256 aa0000e4ea9/Body/M2?OpenElement\"><IMG SRC=\"http://rajanagendra.sun.com/icons/medoc.gif\" BORDER=0 HSPACE=4 ALIGN=middle></A></TD><TD>text/html</TD></TR>\\n</TABLE>\\n</IFRAME>\\n';\n"
0756: + "</script>\n";
0757:
0758: String lHTMLAttRules = "<Attribute name=\"sRC\" />";
0759: String lJSVarRules = "<Variable name=\"BodyHtml\" source=\"*sun.*\" type=\"DHTML\"/>";
0760:
0761: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarJSFunRules(
0762: lHTMLAttRules, lJSVarRules, "");
0763:
0764: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0765: LanguageConstants.HTML_MIME);
0766: String lResult = lRewriter.rewrite(lInput,
0767: getDefaultTranslator());
0768: assertEquals(lExpectation, lResult);
0769: }//testBugNo4494740Varient()
0770:
0771: public void testBugNo4494740Varient1() throws Exception {
0772: String lInput = "<script> \n"
0773: + "var BodyHtml= '<P><IFRAME SRC=\"/mail01/ml12345.nsf/38d46bf5e8f08834852564b500129b2c/5fad94b07273563f85256a a0000e4ea9/Body/M2?OpenElement\" CLASS=\"s-form-bodyiframe\">\\\\n\\\\n<P>\\\\n<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=4>\\\\n<TR VALIGN=middle><TD><A HREF=\"/mail01/ml12345.nsf/38d46bf5e8f08834852564b500129b2c/5fad94b07273563f85256 aa0000e4ea9/Body/M2?OpenElement\"><IMG SRC=\"/icons/medoc.gif\" BORDER=0 HSPACE=4 ALIGN=middle></A></TD><TD>text/html</TD></TR>\\n</TABLE>\\n</IFRAME>\\n';\n"
0774: + "</script>\n";
0775:
0776: String lExpectation = "<script> \n"
0777: + "var BodyHtml= '<P><IFRAME SRC=\"http://rajanagendra.sun.com/mail01/ml12345.nsf/38d46bf5e8f08834852564b500129b2c/5fad94b07273563f85256a a0000e4ea9/Body/M2?OpenElement\" CLASS=\"s-form-bodyiframe\">\\\\n\\\\n<P>\\\\n<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=4>\\\\n<TR VALIGN=middle><TD><A HREF=\"/mail01/ml12345.nsf/38d46bf5e8f08834852564b500129b2c/5fad94b07273563f85256 aa0000e4ea9/Body/M2?OpenElement\"><IMG SRC=\"http://rajanagendra.sun.com/icons/medoc.gif\" BORDER=0 HSPACE=4 ALIGN=middle></A></TD><TD>text/html</TD></TR>\\n</TABLE>\\n</IFRAME>\\n';\n"
0778: + "</script>\n";
0779:
0780: String lHTMLAttRules = "<Attribute name=\"sRC\" />";
0781: String lJSVarRules = "<Variable name=\"BodyHtml\" source=\"*sun.*\" type=\"DHTML\"/>";
0782:
0783: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarJSFunRules(
0784: lHTMLAttRules, lJSVarRules, "");
0785:
0786: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0787: LanguageConstants.HTML_MIME);
0788: String lResult = lRewriter.rewrite(lInput,
0789: getDefaultTranslator());
0790: assertEquals(lExpectation, lResult);
0791: }//testBugNo4494740Varient1()
0792:
0793: public void testComplexDHTMLVar() throws Exception {
0794: String lInput = " html = '<img src=\"' + 'webguiMimeURL' + '/webgui/'+'webguiTheme'+"
0795: + " '/images/buttons/tanicon.gif\" style=\"width:17;height:17\"\\\n"
0796: + " onmouseout=\"status=\\' \\';\"\\\n"
0797: + " onmouseover=\"status=\\'?\\';\"\\\n"
0798: + " href=\"abc.html\"\\\n"
0799: + " onclick=\"javascript:webguiRaiseSearchhelp(\\'' + fieldname + '\\')\">'\n";
0800:
0801: String lExpectation = " html = '<img src=\"' + 'webguiMimeURL' + '/webgui/'+'webguiTheme'+\t\t'/images/buttons/tanicon.gif\" style=\"width:17;height:17\""
0802: + " onmouseout=\"status=\\' \\';\""
0803: + " onmouseover=\"status=\\'?\\';\""
0804: + " href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\""
0805: + " onclick=\"javascript:webguiRaiseSearchhelp(\\'' + fieldname + '\\')\">'\n";
0806:
0807: String lHTMLAttRules = "<Attribute name='href'/>"
0808: + "<Attribute name='on*' type='DJS'/>";
0809:
0810: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
0811:
0812: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
0813: lHTMLAttRules, lJSVarRules);
0814: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0815: LanguageConstants.JS_MIME);
0816: String lResult = lRewriter.rewrite(lInput,
0817: getDefaultTranslator());
0818: assertEquals(lExpectation, lResult);
0819: }//testComplexDHTMLVar()
0820:
0821: public void testComplexDHTMLVarSlashRAndSlashN() throws Exception {
0822: String lInput = " html = '<img src=\"' + 'webguiMimeURL' + '/webgui/'+'webguiTheme'+'/images/buttons/tanicon.gif\" style=\"width:17;height:17\"\\\r\n"
0823: + " onmouseout=\"status=\\' \\';\"\\\r\n"
0824: + " onmouseover=\"status=\\'?\\';\"\\\r\n"
0825: + " href=\"abc.html\"\\\r\n"
0826: + " onclick=\"javascript:webguiRaiseSearchhelp(\\'' + fieldname + '\\')\">'\r\n";
0827:
0828: String lExpectation = " html = '<img src=\"' + 'webguiMimeURL' + '/webgui/'+'webguiTheme'+'/images/buttons/tanicon.gif\" style=\"width:17;height:17\""
0829: + " onmouseout=\"status=\\' \\';\""
0830: + " onmouseover=\"status=\\'?\\';\""
0831: + " href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\""
0832: + " onclick=\"javascript:webguiRaiseSearchhelp(\\'' + fieldname + '\\')\">'\n";
0833:
0834: String lHTMLAttRules = "<Attribute name='href'/>"
0835: + "<Attribute name='on*' type='DJS'/>";
0836:
0837: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
0838:
0839: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
0840: lHTMLAttRules, lJSVarRules);
0841: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0842: LanguageConstants.JS_MIME);
0843: String lResult = lRewriter.rewrite(lInput,
0844: getDefaultTranslator());
0845: assertEquals(lExpectation, lResult);
0846: }//testComplexDHTMLVarSlashRAndSlashN()
0847:
0848: public void testComplexDHTMLVarSlashRAndSlashNSimplefyed()
0849: throws Exception {
0850: String lInput = " html = '<img src=\"abc1.html\" \\\n\\\rhref=\"abc.html\">'\r\n";
0851:
0852: String lExpectation = " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc1.html\" href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n";
0853:
0854: String lHTMLAttRules = "<Attribute name='href;SRC'/>";
0855: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
0856:
0857: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
0858: lHTMLAttRules, lJSVarRules);
0859: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0860: LanguageConstants.JS_MIME);
0861: String lResult = lRewriter.rewrite(lInput,
0862: getDefaultTranslator());
0863: assertEquals(lExpectation, lResult);
0864: }//testComplexDHTMLVarSlashRAndSlashNSimplefyed()
0865:
0866: public void testComplexDHTMLVarSlashRAndSlashNSimplefyed2()
0867: throws Exception {
0868: String lInput = " html = '<img src=\"abc.html\" href=\"abc.html\">'\r\n"
0869: + " html = '<img src=\"abc1.html\" \\\rhref=\"abc.html\">'\r\n"
0870: + " html = '<img src=\"abc1.html\" \\\nhref=\"abc.html\">'\r\n"
0871: + " html = '<img src=\"abc1.html\" \\\r\\\nhref=\"abc.html\">'\r\n"
0872: + " html = '<img src=\"abc1.html\" \\\n\\\rhref=\"abc.html\">'\r\n";
0873:
0874: String lExpectation = " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc.html\" href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n"
0875: + " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc1.html\" href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n"
0876: + " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc1.html\" href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n"
0877: + " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc1.html\" href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n"
0878: + " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc1.html\" href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n";
0879:
0880: String lHTMLAttRules = "<Attribute name='href;SRC'/>";
0881: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
0882:
0883: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
0884: lHTMLAttRules, lJSVarRules);
0885: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0886: LanguageConstants.JS_MIME);
0887: String lResult = lRewriter.rewrite(lInput,
0888: getDefaultTranslator());
0889: assertEquals(lExpectation, lResult);
0890: }//testComplexDHTMLVarSlashRAndSlashNSimplefyed()
0891:
0892: public void testComplexDHTMLVarSlashRAndSlashNSimplefyed1()
0893: throws Exception {
0894: String lInput = " html = '<img src=\"abc.html\" href=\"abc.html\">'\r\n"
0895: + " html = '<img src=\"abc.html\" \\\n\\\rhref=\"abc.html\">'\r\n"
0896: + " html = '<img src=\"abc.html\" \\\r\nhref=\"abc.html\">'\r\n"
0897: + " html = '<img src=\"abc.html\" \\\rhref=\"abc.html\">'\r\n"
0898: + " html = '<img src=\"abc.html\" \\\nhref=\"abc.html\">'\r\n"
0899: + " html = '<img src=\"abc1.html\" \\\rhref=\"abc.html\">'\r\n"
0900: + " html = '<img src=\"abc1.html\" \\\r\nhref=\"abc.html\">'\r\n"
0901: + " html = '<img src=\"abc1.html\" \\\n\\\rhref=\"abc.html\">'\r\n"
0902: + " html = '<img src=\"abc1.html\"\\\n\\\rhref=\"abc.html\">'\r\n"
0903: + " html = '<img src=abc1.html\\\n\\\rhref=\"abc.html\">'\r\n"
0904: +
0905: //" html = '<img src=\"abc1.html\" \\\n\rhref=\"abc.html\">'\r\n" +
0906: " html = '<img src=\"abc1.html\" \\\nhref=\"abc.html\">'\r\n";
0907:
0908: String lExpectation = " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc.html\" href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n"
0909: + " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc.html\" href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n"
0910: + " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc.html\" href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n"
0911: + " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc.html\" href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n"
0912: + " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc.html\" href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n"
0913: + " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc1.html\" href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n"
0914: + " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc1.html\" href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n"
0915: + " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc1.html\" href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n"
0916: + " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc1.html\"href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n"
0917: + " html = '<img src=http://rajanagendra.sun.com/Base/Raja/abc1.htmlhref=\"abc.html\">'\n"
0918: +
0919: //" html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc1.html\" \\\n\rhref=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n" +
0920: " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/abc1.html\" href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n";
0921:
0922: String lHTMLAttRules = "<Attribute name='href;SRC'/>";
0923: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
0924:
0925: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
0926: lHTMLAttRules, lJSVarRules);
0927: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0928: LanguageConstants.JS_MIME);
0929: String lResult = lRewriter.rewrite(lInput,
0930: getDefaultTranslator());
0931: assertEquals(lExpectation, lResult);
0932: }//testComplexDHTMLVarSlashRAndSlashNSimplefyed()
0933:
0934: public void testComplexDHTMLVarSlashNSlashRInvalidJS()
0935: throws Exception {
0936: String lInput = " html = '<img src=\"' + 'webguiMimeURL' + '/webgui/'+'webguiTheme'+'/images/buttons/tanicon.gif\" style=\"width:17;height:17\"\\\n\r"
0937: + " onmouseout=\"status=\\' \\';\"\\\n\r"
0938: + " onmouseover=\"status=\\'?\\';\"\\\n\r"
0939: + " href=\"abc.html\"\\\n\r"
0940: + " onclick=\"javascript:webguiRaiseSearchhelp(\\'' + fieldname + '\\')\">'\n\r";
0941:
0942: String lExpectation = " html = '<img src=\"' + 'webguiMimeURL' + '/webgui/'+'webguiTheme'+'/images/buttons/tanicon.gif\" style=\"width:17;height:17\"\\\n\n"
0943: + " onmouseout=\"status=\\' \\';\"\\\n\n"
0944: + " onmouseover=\"status=\\'?\\';\"\\\n\n"
0945: + " href=\"abc.html\"\\\n\n"
0946: + " onclick=\"javascript:webguiRaiseSearchhelp(\\'' + fieldname + '\\')\">'\n\n";
0947:
0948: String lHTMLAttRules = "<Attribute name='href'/>"
0949: + "<Attribute name='on*' type='DJS'/>";
0950:
0951: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
0952:
0953: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
0954: lHTMLAttRules, lJSVarRules);
0955: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0956: LanguageConstants.JS_MIME);
0957: String lResult = lRewriter.rewrite(lInput,
0958: getDefaultTranslator());
0959: assertEquals(lExpectation, lResult);
0960: }//testComplexDHTMLVarSlashNSlashRInvalidJS()
0961:
0962: public void testComplexDHTMLVarSlashN() throws Exception {
0963: String lInput = " html = '<img src=\"' + 'webguiMimeURL' + '/webgui/'+'webguiTheme'+'/images/buttons/tanicon.gif\" style=\"width:17;height:17\"\\\n"
0964: + " onmouseout=\"status=\\' \\';\"\\\n"
0965: + " onmouseover=\"status=\\'?\\';\"\\\n"
0966: + " href=\"abc.html\"\\\n"
0967: + " onclick=\"javascript:webguiRaiseSearchhelp(\\'' + fieldname + '\\')\">'\n";
0968:
0969: String lExpectation = " html = '<img src=\"' + 'webguiMimeURL' + '/webgui/'+'webguiTheme'+'/images/buttons/tanicon.gif\" style=\"width:17;height:17\""
0970: + " onmouseout=\"status=\\' \\';\""
0971: + " onmouseover=\"status=\\'?\\';\""
0972: + " href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\""
0973: + " onclick=\"javascript:webguiRaiseSearchhelp(\\'' + fieldname + '\\')\">'\n";
0974:
0975: String lHTMLAttRules = "<Attribute name='href'/>"
0976: + "<Attribute name='on*' type='DJS'/>";
0977:
0978: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
0979:
0980: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
0981: lHTMLAttRules, lJSVarRules);
0982: Rewriter lRewriter = RewriterPool.create(lRuleSet,
0983: LanguageConstants.JS_MIME);
0984: String lResult = lRewriter.rewrite(lInput,
0985: getDefaultTranslator());
0986: assertEquals(lExpectation, lResult);
0987: }//testComplexDHTMLVarSlashN()
0988:
0989: public void testEscapedLinesNoNewLineBugEscape() throws Exception {
0990: String lInput = " html = '<a \\"
0991: + " href=\"abc.html\"/>'"
0992: + " html = '<a href=\"abc.html\"/>'";
0993:
0994: String lExpectation = " html = '<a \\"
0995: + " href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\"/>'"
0996: + " html = '<a href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\"/>'";
0997:
0998: String lHTMLAttRules = "<Attribute name='href'/>";
0999: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
1000:
1001: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
1002: lHTMLAttRules, lJSVarRules);
1003: Rewriter lRewriter = RewriterPool.create(lRuleSet,
1004: LanguageConstants.JS_MIME);
1005: String lResult = lRewriter.rewrite(lInput,
1006: getDefaultTranslator());
1007: assertEquals(lExpectation, lResult);
1008: }//testEscapedLinesNoNewLineBugEscape()
1009:
1010: public void testEscapedLinesSlashN() throws Exception {
1011: String lInput = " html = '<a \\\n"
1012: + " href=\"abc.html\"/>';"
1013: + " html = '<a href=\"abc.html\"/>';";
1014:
1015: String lExpectation = " html = '<a href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\"/>';"
1016: + " html = '<a href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\"/>';";
1017:
1018: String lHTMLAttRules = "<Attribute name='href'/>";
1019: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
1020:
1021: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
1022: lHTMLAttRules, lJSVarRules);
1023: Rewriter lRewriter = RewriterPool.create(lRuleSet,
1024: LanguageConstants.JS_MIME);
1025: String lResult = lRewriter.rewrite(lInput,
1026: getDefaultTranslator());
1027: assertEquals(lExpectation, lResult);
1028: }//testEscapedLinesSlashN()
1029:
1030: public void testEscapedLinesSlashR() throws Exception {
1031: String lInput = " html = '<a \t\\\r"
1032: + " href=\"abc.html\"/>';"
1033: + " html = '<a href=\"abc.html\"/>';";
1034:
1035: String lExpectation = " html = '<a \t href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\"/>';"
1036: + " html = '<a href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\"/>';";
1037:
1038: String lHTMLAttRules = "<Attribute name='href'/>";
1039: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
1040:
1041: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
1042: lHTMLAttRules, lJSVarRules);
1043: Rewriter lRewriter = RewriterPool.create(lRuleSet,
1044: LanguageConstants.JS_MIME);
1045: String lResult = lRewriter.rewrite(lInput,
1046: getDefaultTranslator());
1047: assertEquals(lExpectation, lResult);
1048: }//testEscapedLinesSlashR()
1049:
1050: public void testEscapedLinesSlashNRInvalidJS() throws Exception {
1051: //some problem with \n\r prefixed by \\
1052: String lInput = " html = '<a \\\n\\\r"
1053: + " href=\"abc.html\"/>';"
1054: + " html = '<a href=\"abc.html\"/>';";
1055:
1056: String lExpectation = " html = '<a href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\"/>';"
1057: + " html = '<a href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\"/>';";
1058:
1059: String lHTMLAttRules = "<Attribute name='href'/>";
1060: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
1061:
1062: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
1063: lHTMLAttRules, lJSVarRules);
1064: Rewriter lRewriter = RewriterPool.create(lRuleSet,
1065: LanguageConstants.JS_MIME);
1066: String lResult = lRewriter.rewrite(lInput,
1067: getDefaultTranslator());
1068: assertEquals(lExpectation, lResult);
1069: }//testEscapedLinesSlashNRInvalidJS()
1070:
1071: public void testEscapedLinesSlashNR() throws Exception {
1072: String lInput = " html = '<a \\\n\\\r"
1073: + " href=\"abc.html\"/>';\r\n"
1074: + " html = '<a href=\"abc.html\"/>';";
1075:
1076: String lExpectation = " html = '<a href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\"/>';\n"
1077: + " html = '<a href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\"/>';";
1078:
1079: String lHTMLAttRules = "<Attribute name='href'/>";
1080: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
1081:
1082: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
1083: lHTMLAttRules, lJSVarRules);
1084: Rewriter lRewriter = RewriterPool.create(lRuleSet,
1085: LanguageConstants.JS_MIME);
1086: String lResult = lRewriter.rewrite(lInput,
1087: getDefaultTranslator());
1088: assertEquals(lExpectation, lResult);
1089: }//testEscapedLinesSlashNRInvalidJS()
1090:
1091: public void testEscapedLinesSlashRN() throws Exception {
1092: //parser is converting \r\n --> \n
1093: String lInput = " html = '<a \\\r\n"
1094: + " href=\"abc.html\"/>';"
1095: + " html = '<a href=\"abc.html\"/>';";
1096:
1097: String lExpectation = " html = '<a href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\"/>';"
1098: + " html = '<a href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\"/>';";
1099:
1100: String lHTMLAttRules = "<Attribute name='href'/>";
1101: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
1102:
1103: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
1104: lHTMLAttRules, lJSVarRules);
1105: Rewriter lRewriter = RewriterPool.create(lRuleSet,
1106: LanguageConstants.JS_MIME);
1107: String lResult = lRewriter.rewrite(lInput,
1108: getDefaultTranslator());
1109: assertEquals(lExpectation, lResult);
1110: }//testEscapedLinesSlashRN()
1111:
1112: public void testComplexDHTMLVarSlashNSlashRHREFinFirstLine()
1113: throws Exception {
1114: String lInput = " html = '<img href=\"abc.html\" src=\"' + 'webguiMimeURL' + '/webgui/'+'webguiTheme'+'/images/buttons/tanicon.gif\" style=\"width:17;height:17\"\\\n\r"
1115: + " onmouseout=\"status=\\' \\';\"\\\n\r"
1116: + " onmouseover=\"status=\\'?\\';\"\\\n\r"
1117: + " href=\"abc.html\"\\\n\r"
1118: + " onclick=\"javascript:webguiRaiseSearchhelp(\\'' + fieldname + '\\')\">'\n\r";
1119:
1120: String lExpectation = " html = '<img href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\" src=\"' + 'webguiMimeURL' + '/webgui/'+'webguiTheme'+'/images/buttons/tanicon.gif\" style=\"width:17;height:17\"\\\n\n"
1121: + " onmouseout=\"status=\\' \\';\"\\\n\n"
1122: + " onmouseover=\"status=\\'?\\';\"\\\n\n"
1123: + " href=\"abc.html\"\\\n\n"
1124: + " onclick=\"javascript:webguiRaiseSearchhelp(\\'' + fieldname + '\\')\">'\n\n";
1125:
1126: String lHTMLAttRules = "<Attribute name='href'/>"
1127: + "<Attribute name='on*' type='DJS'/>";
1128:
1129: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
1130:
1131: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
1132: lHTMLAttRules, lJSVarRules);
1133: Rewriter lRewriter = RewriterPool.create(lRuleSet,
1134: LanguageConstants.JS_MIME);
1135: String lResult = lRewriter.rewrite(lInput,
1136: getDefaultTranslator());
1137: assertEquals(lExpectation, lResult);
1138: }//testComplexDHTMLVarSlashNSlashRHREFinFirstLine()
1139:
1140: public void testComplexDHTMLVarTotalInSingleLine() throws Exception {
1141: String lInput = " html = '<img src=\"' + 'webguiMimeURL' + '/webgui/'+'webguiTheme'+'/images/buttons/tanicon.gif\" style=\"width:17;height:17\""
1142: + " onmouseout=\"status=\\' \\';\""
1143: + " onmouseover=\"status=\\'?\\';\""
1144: + " href=\"abc.html\""
1145: + " onclick=\"javascript:webguiRaiseSearchhelp(\\'' + fieldname + '\\')\" "
1146: + " href=\"abc.html\">'\n";
1147:
1148: String lExpectation = " html = '<img src=\"' + 'webguiMimeURL' + '/webgui/'+'webguiTheme'+'/images/buttons/tanicon.gif\" style=\"width:17;height:17\""
1149: + " onmouseout=\"status=\\' \\';\""
1150: + " onmouseover=\"status=\\'?\\';\""
1151: + " href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\""
1152: + " onclick=\"javascript:webguiRaiseSearchhelp(\\'' + fieldname + '\\')\" "
1153: + " href=\"http://rajanagendra.sun.com/Base/Raja/abc.html\">'\n";
1154:
1155: String lHTMLAttRules = "<Attribute name='href'/>"
1156: + "<Attribute name='on*' type='DJS'/>";
1157:
1158: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
1159:
1160: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
1161: lHTMLAttRules, lJSVarRules);
1162: Rewriter lRewriter = RewriterPool.create(lRuleSet,
1163: LanguageConstants.JS_MIME);
1164: String lResult = lRewriter.rewrite(lInput,
1165: getDefaultTranslator());
1166: assertEquals(lExpectation, lResult);
1167: }//testComplexDHTMLVarTotalInSingleLine()
1168:
1169: public void testSplittedDHTMLString() throws Exception {
1170: String lInput = "html = '<img src=\"../images/\\\n\\\n\\\n\\\n\\\n\\\n"
1171: + "abc.gif\"';\n";
1172:
1173: String lExpectation = "html = '<img src=\"http://rajanagendra.sun.com/Base/images/abc.gif\"';\n";
1174:
1175: String lHTMLAttRules = "<Attribute name='Sr*'/>";
1176:
1177: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
1178:
1179: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
1180: lHTMLAttRules, lJSVarRules);
1181: Rewriter lRewriter = RewriterPool.create(lRuleSet,
1182: LanguageConstants.JS_MIME);
1183: String lResult = lRewriter.rewrite(lInput,
1184: getDefaultTranslator());
1185: assertEquals(lExpectation, lResult);
1186: }//testSplittedDHTMLString()
1187:
1188: public void testSplittedDHTMLStringVarientNoSpace()
1189: throws Exception {
1190: String lInput = "html = \n" + "'<img src=\"images/\\\n"
1191: + "abc.gif\"';\n";
1192:
1193: String lExpectation = "html = \n"
1194: + "'<img src=\"http://rajanagendra.sun.com/Base/Raja/images/abc.gif\"';\n";
1195:
1196: String lHTMLAttRules = "<Attribute name='*src*'/>";
1197:
1198: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
1199:
1200: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
1201: lHTMLAttRules, lJSVarRules);
1202: Rewriter lRewriter = RewriterPool.create(lRuleSet,
1203: LanguageConstants.JS_MIME);
1204: String lResult = lRewriter.rewrite(lInput,
1205: getDefaultTranslator());
1206: assertEquals(lExpectation, lResult);
1207: }//testSplittedDHTMLString()
1208:
1209: public void testSplittedDHTMLStringSpaces() throws Exception {
1210: String lInput = " html = '<img href=\"/images/\\\n"
1211: + "abc.gif\"';\n";
1212:
1213: String lExpectation = " html = '<img href=\"http://rajanagendra.sun.com/images/abc.gif\"';\n";
1214:
1215: String lHTMLAttRules = "<Attribute name='href'/>";
1216:
1217: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
1218:
1219: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
1220: lHTMLAttRules, lJSVarRules);
1221: Rewriter lRewriter = RewriterPool.create(lRuleSet,
1222: LanguageConstants.JS_MIME);
1223: String lResult = lRewriter.rewrite(lInput,
1224: getDefaultTranslator());
1225: assertEquals(lExpectation, lResult);
1226: }//testSplittedDHTMLStringSpaces()
1227:
1228: public void testSplittedDHTMLStringSpacesVarient() throws Exception {
1229: String lInput = " html = '<img src=\"images/\\\n"
1230: + "abc.gif\">';\n";
1231:
1232: String lExpectation = " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/images/abc.gif\">';\n";
1233:
1234: String lHTMLAttRules = "<Attribute name='src'/>";
1235:
1236: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
1237:
1238: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
1239: lHTMLAttRules, lJSVarRules);
1240: Rewriter lRewriter = RewriterPool.create(lRuleSet,
1241: LanguageConstants.JS_MIME);
1242: String lResult = lRewriter.rewrite(lInput,
1243: getDefaultTranslator());
1244: assertEquals(lExpectation, lResult);
1245: }//testSplittedDHTMLStringSpacesVarient()
1246:
1247: public void testSplittedDHTMLStringSpacesVarientMultiLine()
1248: throws Exception {
1249: String lInput = " html = '<im\\\r\n\\\rg\\\n s\\\nr\\\nc=\"im\\\na\\\nge\\\ns/\\\n"
1250: + "abc.gif\">';\n";
1251:
1252: String lExpectation = " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/images/abc.gif\">';\n";
1253:
1254: String lHTMLAttRules = "<Attribute name='src'/>";
1255:
1256: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
1257:
1258: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
1259: lHTMLAttRules, lJSVarRules);
1260: Rewriter lRewriter = RewriterPool.create(lRuleSet,
1261: LanguageConstants.JS_MIME);
1262: String lResult = lRewriter.rewrite(lInput,
1263: getDefaultTranslator());
1264: assertEquals(lExpectation, lResult);
1265: }//testSplittedDHTMLStringSpacesVarientMultiLine()
1266:
1267: public void testSplittedDHTMLStringSpacesVarientSingleLine()
1268: throws Exception {
1269: String lInput = " html = '<img src=\"images/abc.gif\">';\n";
1270:
1271: String lExpectation = " html = '<img src=\"http://rajanagendra.sun.com/Base/Raja/images/abc.gif\">';\n";
1272:
1273: String lHTMLAttRules = "<Attribute name='src'/>";
1274:
1275: String lJSVarRules = "<Variable name=\"html\" type=\"DHTML\"/>";
1276:
1277: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
1278: lHTMLAttRules, lJSVarRules);
1279: Rewriter lRewriter = RewriterPool.create(lRuleSet,
1280: LanguageConstants.JS_MIME);
1281: String lResult = lRewriter.rewrite(lInput,
1282: getDefaultTranslator());
1283: assertEquals(lExpectation, lResult);
1284: }//testSplittedDHTMLStringSpacesVarientSingleLine()
1285:
1286: public void testDHTMLObjectProperties() throws Exception {
1287: String lInput = "ur_system = {doc : window.document , mimepath :\"<a href=/irj/portalapps/com.sap.portal.themes.lafservice/themes/portal/sap_standard/common/>\", stylepath : \"/irj/portalapps/com.sap.portal.themes.lafservice/themes/portal/sap_standard/ur/\", is508 : false};\n";
1288:
1289: String lExpectation = "ur_system = {doc : window.document , mimepath :\"<a href=http://rajanagendra.sun.com/irj/portalapps/com.sap.portal.themes.lafservice/themes/portal/sap_standard/common/>\", stylepath : \"http://rajanagendra.sun.com/irj/portalapps/com.sap.portal.themes.lafservice/themes/portal/sap_standard/ur/\", is508 : false};\n";
1290:
1291: String lHTMLAttRules = "<Attribute name='HREF'/>";
1292:
1293: String lJSVarRules = " <Variable name = 'mimepath' type=\"DHTML\"/>\n"
1294: + " <Variable name = 'stylepath' type=\"URL\"/>\n";
1295:
1296: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarRules(
1297: lHTMLAttRules, lJSVarRules);
1298: Rewriter lRewriter = RewriterPool.create(lRuleSet,
1299: LanguageConstants.JS_MIME);
1300: String lResult = lRewriter.rewrite(lInput,
1301: getDefaultJSTranslator());
1302: assertEquals(lExpectation, lResult);
1303: }//testDHTMLObjectProperties()
1304:
1305: public static void main(String[] args) {
1306: RewriterModule.initFile();
1307: BasicTestCase.run(TestJSDHTMLVariables.class);
1308:
1309: TestSuite testSuite = new TestSuite();
1310: testSuite.addTest(new TestJSDHTMLVariables(
1311: "testComplexDHTMLVarSlashNSlashRInvalidJS"));
1312: //BasicTestCase.run( testSuite );
1313: }//main()
1314:
1315: }//class TestJSDHTMLVariables
|