aboutsummaryrefslogtreecommitdiffstats
path: root/website/resources/scripts/testcases2/15.1.3.4_encodeURIComponent.json
diff options
context:
space:
mode:
Diffstat (limited to 'website/resources/scripts/testcases2/15.1.3.4_encodeURIComponent.json')
-rw-r--r--website/resources/scripts/testcases2/15.1.3.4_encodeURIComponent.json176
1 files changed, 176 insertions, 0 deletions
diff --git a/website/resources/scripts/testcases2/15.1.3.4_encodeURIComponent.json b/website/resources/scripts/testcases2/15.1.3.4_encodeURIComponent.json
new file mode 100644
index 000000000..9ccb5ee2e
--- /dev/null
+++ b/website/resources/scripts/testcases2/15.1.3.4_encodeURIComponent.json
@@ -0,0 +1,176 @@
+{
+ "testCollection": {
+ "name": "15.1.3.4_encodeURIComponent",
+ "numTests": 28,
+ "tests": [
+ {
+ "section": "15.1.3.4",
+ "description": "Complex tests",
+ "test": "errorCount = 0;\ncount = 0;\nvar indexP;\nvar indexO = 0;\n\nfor (index = 0xDC00; index <= 0xDFFF; index++) {\n count++; \n hex = decimalToHexString(index);\n try {\n encodeURIComponent(String.fromCharCode(index));\n } catch (e) { \n if ((e instanceof URIError) === true) continue; \n }\n if (indexO === 0) { \n indexO = index;\n } else {\n if ((index - indexP) !== 1) { \n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } \n else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n indexO = index;\n } \n }\n indexP = index;\n errorCount++; \n}\n\nif (errorCount > 0) {\n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');\n}\n\nfunction decimalToHexString(n) {\n n = Number(n);\n var h = \"\";\n for (var i = 3; i >= 0; i--) {\n if (n >= Math.pow(16, i)) {\n var t = Math.floor(n / Math.pow(16, i));\n n -= t * Math.pow(16, i);\n if ( t >= 10 ) {\n if ( t == 10 ) { h += \"A\"; }\n if ( t == 11 ) { h += \"B\"; }\n if ( t == 12 ) { h += \"C\"; }\n if ( t == 13 ) { h += \"D\"; }\n if ( t == 14 ) { h += \"E\"; }\n if ( t == 15 ) { h += \"F\"; }\n } else {\n h += String(t);\n }\n } else {\n h += \"0\";\n }\n }\n return h;\n}\n",
+ "id": "S15.1.3.4_A1.1_T1"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Complex tests",
+ "test": "errorCount = 0;\ncount = 0;\nvar indexP;\nvar indexO = 0;\n\nfor (index = 0xDC00; index <= 0xDFFF; index++) { \n count++; \n hex = decimalToHexString(index);\n try {\n encodeURIComponent(String.fromCharCode(index, 0x0041));\n } catch (e) { \n if ((e instanceof URIError) === true) continue; \n }\n if (indexO === 0) { \n indexO = index;\n } else {\n if ((index - indexP) !== 1) { \n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } \n else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n indexO = index;\n } \n }\n indexP = index;\n errorCount++; \n}\n\nif (errorCount > 0) {\n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');\n}\n\nfunction decimalToHexString(n) {\n n = Number(n);\n var h = \"\";\n for (var i = 3; i >= 0; i--) {\n if (n >= Math.pow(16, i)) {\n var t = Math.floor(n / Math.pow(16, i));\n n -= t * Math.pow(16, i);\n if ( t >= 10 ) {\n if ( t == 10 ) { h += \"A\"; }\n if ( t == 11 ) { h += \"B\"; }\n if ( t == 12 ) { h += \"C\"; }\n if ( t == 13 ) { h += \"D\"; }\n if ( t == 14 ) { h += \"E\"; }\n if ( t == 15 ) { h += \"F\"; }\n } else {\n h += String(t);\n }\n } else {\n h += \"0\";\n }\n }\n return h;\n}\n",
+ "id": "S15.1.3.4_A1.1_T2"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Complex tests",
+ "test": "errorCount = 0;\ncount = 0;\nvar indexP;\nvar indexO = 0;\n\nfor (index = 0xD800; index <= 0xDBFF; index++) {\n count++; \n hex = decimalToHexString(index);\n try {\n encodeURIComponent(String.fromCharCode(index));\n } catch (e) { \n if ((e instanceof URIError) === true) continue; \n }\n if (indexO === 0) { \n indexO = index;\n } else {\n if ((index - indexP) !== 1) { \n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } \n else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n indexO = index;\n } \n }\n indexP = index;\n errorCount++; \n}\n\nif (errorCount > 0) {\n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');\n}\n\nfunction decimalToHexString(n) {\n n = Number(n);\n var h = \"\";\n for (var i = 3; i >= 0; i--) {\n if (n >= Math.pow(16, i)) {\n var t = Math.floor(n / Math.pow(16, i));\n n -= t * Math.pow(16, i);\n if ( t >= 10 ) {\n if ( t == 10 ) { h += \"A\"; }\n if ( t == 11 ) { h += \"B\"; }\n if ( t == 12 ) { h += \"C\"; }\n if ( t == 13 ) { h += \"D\"; }\n if ( t == 14 ) { h += \"E\"; }\n if ( t == 15 ) { h += \"F\"; }\n } else {\n h += String(t);\n }\n } else {\n h += \"0\";\n }\n }\n return h;\n}\n",
+ "id": "S15.1.3.4_A1.2_T1"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Complex tests",
+ "test": "errorCount = 0;\ncount = 0;\nvar indexP;\nvar indexO = 0;\n\nfor (index = 0xD800; index <= 0xDBFF; index++) { \n count++; \n hex = decimalToHexString(index);\n try {\n encodeURIComponent(String.fromCharCode(0x0041, index));\n } catch (e) { \n if ((e instanceof URIError) === true) continue; \n }\n if (indexO === 0) { \n indexO = index;\n } else {\n if ((index - indexP) !== 1) { \n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } \n else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n indexO = index;\n } \n }\n indexP = index;\n errorCount++; \n}\n\nif (errorCount > 0) {\n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');\n}\n\nfunction decimalToHexString(n) {\n n = Number(n);\n var h = \"\";\n for (var i = 3; i >= 0; i--) {\n if (n >= Math.pow(16, i)) {\n var t = Math.floor(n / Math.pow(16, i));\n n -= t * Math.pow(16, i);\n if ( t >= 10 ) {\n if ( t == 10 ) { h += \"A\"; }\n if ( t == 11 ) { h += \"B\"; }\n if ( t == 12 ) { h += \"C\"; }\n if ( t == 13 ) { h += \"D\"; }\n if ( t == 14 ) { h += \"E\"; }\n if ( t == 15 ) { h += \"F\"; }\n } else {\n h += String(t);\n }\n } else {\n h += \"0\";\n }\n }\n return h;\n}\n",
+ "id": "S15.1.3.4_A1.2_T2"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Complex tests, string.charAt(k+1) in [0x0000, 0xD7FF, 0xD800, 0xDBFE, 0xDBFF, 0xE000, 0xFFFF]",
+ "test": "chars = [0x0000, 0xD7FF, 0xD800, 0xDBFE, 0xDBFF, 0xE000, 0xFFFF];\nerrorCount = 0;\ncount = 0;\nvar indexP;\nvar indexO = 0;\n\nfor (index = 0xD800; index <= 0xDBFF; index++) {\n count++; \n res = true;\n for (indexC = 0; indexC < chars.length; indexC++) { \n hex = decimalToHexString(index);\n try {\n encodeURIComponent(String.fromCharCode(index, chars[indexC])); \n } catch (e) { \n if ((e instanceof URIError) === true) continue;\n }\n res = false;\n }\n if (res !== true) {\n if (indexO === 0) { \n indexO = index;\n } else {\n if ((index - indexP) !== 1) { \n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } \n else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n indexO = index;\n } \n }\n indexP = index;\n errorCount++; \n } \n}\n\nif (errorCount > 0) {\n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');\n}\n\nfunction decimalToHexString(n) {\n n = Number(n);\n var h = \"\";\n for (var i = 3; i >= 0; i--) {\n if (n >= Math.pow(16, i)) {\n var t = Math.floor(n / Math.pow(16, i));\n n -= t * Math.pow(16, i);\n if ( t >= 10 ) {\n if ( t == 10 ) { h += \"A\"; }\n if ( t == 11 ) { h += \"B\"; }\n if ( t == 12 ) { h += \"C\"; }\n if ( t == 13 ) { h += \"D\"; }\n if ( t == 14 ) { h += \"E\"; }\n if ( t == 15 ) { h += \"F\"; }\n } else {\n h += String(t);\n }\n } else {\n h += \"0\";\n }\n }\n return h;\n}\n",
+ "id": "S15.1.3.4_A1.3_T1"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Complex tests, use RFC 3629",
+ "test": "uriUnescaped = [\"-\", \"_\", \".\", \"!\", \"~\", \"*\", \"'\", \"(\", \")\", \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\", \"K\", \"L\", \"M\", \"N\", \"O\", \"P\", \"Q\", \"R\", \"S\", \"T\", \"U\", \"V\", \"W\", \"X\", \"Y\", \"Z\", \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\", \"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"]; \nerrorCount = 0;\ncount = 0;\nvar indexP;\nvar indexO = 0;\n\nl : \nfor (index = 0x0000; index <= 0x007F; index++) {\n count++;\n str = String.fromCharCode(index);\n for (indexC = 0; indexC < uriUnescaped.length; indexC++) {\n if (uriUnescaped[indexC] === str) continue l;\n } \n try {\n if (encodeURIComponent(str).toUpperCase() === \"%\" + decimalToHexString(index).substring(2)) continue l; \n } catch(e) {} \n if (indexO === 0) { \n indexO = index;\n } else {\n if ((index - indexP) !== 1) { \n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } \n else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n indexO = index;\n } \n }\n indexP = index;\n errorCount++; \n}\n\nif (errorCount > 0) {\n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');\n}\n\nfunction decimalToHexString(n) {\n n = Number(n);\n var h = \"\";\n for (var i = 3; i >= 0; i--) {\n if (n >= Math.pow(16, i)) {\n var t = Math.floor(n / Math.pow(16, i));\n n -= t * Math.pow(16, i);\n if ( t >= 10 ) {\n if ( t == 10 ) { h += \"A\"; }\n if ( t == 11 ) { h += \"B\"; }\n if ( t == 12 ) { h += \"C\"; }\n if ( t == 13 ) { h += \"D\"; }\n if ( t == 14 ) { h += \"E\"; }\n if ( t == 15 ) { h += \"F\"; }\n } else {\n h += String(t);\n }\n } else {\n h += \"0\";\n }\n }\n return h;\n}\n",
+ "id": "S15.1.3.4_A2.1_T1"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Complex tests, use RFC 3629",
+ "test": "errorCount = 0;\ncount = 0;\nvar indexP;\nvar indexO = 0; \nl:\nfor (index = 0x0080; index <= 0x07FF; index++) {\n count++; \n hex1 = decimalToHexString(0x0080 + (index & 0x003F)).substring(2);\n hex2 = decimalToHexString(0x00C0 + (index & 0x07C0) / 0x0040).substring(2); \n str = String.fromCharCode(index);\n try {\n if (encodeURIComponent(str).toUpperCase() === \"%\" + hex2 + \"%\" + hex1) continue;\n } catch(e) {} \n if (indexO === 0) { \n indexO = index;\n } else {\n if ((index - indexP) !== 1) { \n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } \n else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n indexO = index;\n } \n }\n indexP = index;\n errorCount++; \n}\n\nif (errorCount > 0) {\n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');\n}\n\nfunction decimalToHexString(n) {\n n = Number(n);\n var h = \"\";\n for (var i = 3; i >= 0; i--) {\n if (n >= Math.pow(16, i)) {\n var t = Math.floor(n / Math.pow(16, i));\n n -= t * Math.pow(16, i);\n if ( t >= 10 ) {\n if ( t == 10 ) { h += \"A\"; }\n if ( t == 11 ) { h += \"B\"; }\n if ( t == 12 ) { h += \"C\"; }\n if ( t == 13 ) { h += \"D\"; }\n if ( t == 14 ) { h += \"E\"; }\n if ( t == 15 ) { h += \"F\"; }\n } else {\n h += String(t);\n }\n } else {\n h += \"0\";\n }\n }\n return h;\n}\n",
+ "id": "S15.1.3.4_A2.2_T1"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Complex tests, use RFC 3629",
+ "test": "errorCount = 0;\ncount = 0;\nvar indexP;\nvar indexO = 0; \nfor (index = 0x0800; index <= 0xD7FF; index++) {\n count++; \n hex1 = decimalToHexString(0x0080 + (index & 0x003F)).substring(2);\n hex2 = decimalToHexString(0x0080 + (index & 0x0FC0) / 0x0040).substring(2);\n hex3 = decimalToHexString(0x00E0 + (index & 0xF000) / 0x1000).substring(2);\n str = String.fromCharCode(index);\n try {\n if (encodeURIComponent(str).toUpperCase() === \"%\" + hex3 + \"%\" + hex2 + \"%\" + hex1) continue;\n } catch(e) {} \n if (indexO === 0) { \n indexO = index;\n } else {\n if ((index - indexP) !== 1) { \n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } \n else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n indexO = index;\n } \n }\n indexP = index;\n errorCount++; \n} \n\nif (errorCount > 0) {\n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');\n}\n\nfunction decimalToHexString(n) {\n n = Number(n);\n var h = \"\";\n for (var i = 3; i >= 0; i--) {\n if (n >= Math.pow(16, i)) {\n var t = Math.floor(n / Math.pow(16, i));\n n -= t * Math.pow(16, i);\n if ( t >= 10 ) {\n if ( t == 10 ) { h += \"A\"; }\n if ( t == 11 ) { h += \"B\"; }\n if ( t == 12 ) { h += \"C\"; }\n if ( t == 13 ) { h += \"D\"; }\n if ( t == 14 ) { h += \"E\"; }\n if ( t == 15 ) { h += \"F\"; }\n } else {\n h += String(t);\n }\n } else {\n h += \"0\";\n }\n }\n return h;\n}\n",
+ "id": "S15.1.3.4_A2.3_T1"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Complex tests, use RFC 3629, string.charAt(k+1) in [0xDC00, 0xDDFF, 0xDFFF]",
+ "test": "chars = [0xDC00, 0xDDFF, 0xDFFF]; \nerrorCount = 0;\ncount = 0;\nvar indexP;\nvar indexO = 0; \nfor (index = 0xD800; index <= 0xDBFF; index++) {\n res = true;\n for (indexC = 0; indexC < chars.length; indexC++) {\n index1 = (index - 0xD800) * 0x400 + (chars[indexC] - 0xDC00) + 0x10000; \n hex1 = decimalToHexString(0x0080 + (index1 & 0x003F)).substring(2);\n hex2 = decimalToHexString(0x0080 + (index1 & 0x0FC0) / 0x0040).substring(2);\n hex3 = decimalToHexString(0x0080 + (index1 & 0x3F000) / 0x1000).substring(2);\n hex4 = decimalToHexString(0x00F0 + (index1 & 0x1C0000) / 0x40000).substring(2);\n str = String.fromCharCode(index, chars[indexC]);\n try {\n if (encodeURIComponent(str).toUpperCase() !== \"%\" + hex4 + \"%\" + hex3 + \"%\" + hex2 + \"%\" + hex1) {\n res = false;\n }\n } catch(e) {res = false} \n }\n if (res !== true) { \n if (indexO === 0) { \n indexO = index;\n } else {\n if ((index - indexP) !== 1) { \n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } \n else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n indexO = index;\n } \n }\n indexP = index;\n errorCount++; \n }\n count++; \n}\n\nif (errorCount > 0) {\n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');\n}\n\nfunction decimalToHexString(n) {\n n = Number(n);\n var h = \"\";\n for (var i = 3; i >= 0; i--) {\n if (n >= Math.pow(16, i)) {\n var t = Math.floor(n / Math.pow(16, i));\n n -= t * Math.pow(16, i);\n if ( t >= 10 ) {\n if ( t == 10 ) { h += \"A\"; }\n if ( t == 11 ) { h += \"B\"; }\n if ( t == 12 ) { h += \"C\"; }\n if ( t == 13 ) { h += \"D\"; }\n if ( t == 14 ) { h += \"E\"; }\n if ( t == 15 ) { h += \"F\"; }\n } else {\n h += String(t);\n }\n } else {\n h += \"0\";\n }\n }\n return h;\n}\n",
+ "id": "S15.1.3.4_A2.4_T1"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Complex tests, use RFC 3629, string.charAt(k) in [0xD800, 0xDBFF, 0xD9FF]",
+ "test": "chars = [0xD800, 0xDBFF, 0xD9FF]; \nerrorCount = 0;\ncount = 0;\nvar indexP;\nvar indexO = 0; \nfor (index = 0xDC00; index <= 0xDFFF; index++) {\n res = true;\n for (indexC = 0; indexC < chars.length; indexC++) {\n index1 = (chars[indexC] - 0xD800) * 0x400 + (index - 0xDC00) + 0x10000; \n hex1 = decimalToHexString(0x0080 + (index1 & 0x003F)).substring(2);\n hex2 = decimalToHexString(0x0080 + (index1 & 0x0FC0) / 0x0040).substring(2);\n hex3 = decimalToHexString(0x0080 + (index1 & 0x3F000) / 0x1000).substring(2);\n hex4 = decimalToHexString(0x00F0 + (index1 & 0x1C0000) / 0x40000).substring(2);\n str = String.fromCharCode(chars[indexC], index);\n try {\n if (encodeURIComponent(str).toUpperCase() !== \"%\" + hex4 + \"%\" + hex3 + \"%\" + hex2 + \"%\" + hex1) {\n res = false;\n }\n } catch(e) {res = false} \n }\n if (res !== true) { \n if (indexO === 0) { \n indexO = index;\n } else {\n if ((index - indexP) !== 1) { \n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } \n else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n indexO = index;\n } \n }\n indexP = index;\n errorCount++; \n }\n count++; \n}\n\nif (errorCount > 0) {\n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');\n}\n\nfunction decimalToHexString(n) {\n n = Number(n);\n var h = \"\";\n for (var i = 3; i >= 0; i--) {\n if (n >= Math.pow(16, i)) {\n var t = Math.floor(n / Math.pow(16, i));\n n -= t * Math.pow(16, i);\n if ( t >= 10 ) {\n if ( t == 10 ) { h += \"A\"; }\n if ( t == 11 ) { h += \"B\"; }\n if ( t == 12 ) { h += \"C\"; }\n if ( t == 13 ) { h += \"D\"; }\n if ( t == 14 ) { h += \"E\"; }\n if ( t == 15 ) { h += \"F\"; }\n } else {\n h += String(t);\n }\n } else {\n h += \"0\";\n }\n }\n return h;\n}\n",
+ "id": "S15.1.3.4_A2.4_T2"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Complex tests, use RFC 3629",
+ "test": "errorCount = 0;\ncount = 0;\nvar indexP;\nvar indexO = 0; \nfor (index = 0xE000; index <= 0xFFFF; index++) {\n count++; \n hex1 = decimalToHexString(0x0080 + (index & 0x003F)).substring(2);\n hex2 = decimalToHexString(0x0080 + (index & 0x0FC0) / 0x0040).substring(2);\n hex3 = decimalToHexString(0x00E0 + (index & 0xF000) / 0x1000).substring(2);\n str = String.fromCharCode(index);\n try {\n if (encodeURIComponent(str).toUpperCase() === \"%\" + hex3 + \"%\" + hex2 + \"%\" + hex1) continue;\n } catch(e) {} \n if (indexO === 0) { \n indexO = index;\n } else {\n if ((index - indexP) !== 1) { \n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } \n else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n indexO = index;\n } \n }\n indexP = index;\n errorCount++; \n}\n\nif (errorCount > 0) {\n if ((indexP - indexO) !== 0) {\n var hexP = decimalToHexString(indexP);\n var hexO = decimalToHexString(indexO);\n $ERROR('#' + hexO + '-' + hexP + ' ');\n } else {\n var hexP = decimalToHexString(indexP);\n $ERROR('#' + hexP + ' ');\n } \n $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');\n}\n\nfunction decimalToHexString(n) {\n n = Number(n);\n var h = \"\";\n for (var i = 3; i >= 0; i--) {\n if (n >= Math.pow(16, i)) {\n var t = Math.floor(n / Math.pow(16, i));\n n -= t * Math.pow(16, i);\n if ( t >= 10 ) {\n if ( t == 10 ) { h += \"A\"; }\n if ( t == 11 ) { h += \"B\"; }\n if ( t == 12 ) { h += \"C\"; }\n if ( t == 13 ) { h += \"D\"; }\n if ( t == 14 ) { h += \"E\"; }\n if ( t == 15 ) { h += \"F\"; }\n } else {\n h += String(t);\n }\n } else {\n h += \"0\";\n }\n }\n return h;\n}\n",
+ "id": "S15.1.3.4_A2.5_T1"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Complex tests",
+ "test": "uriReserved = [\"%3B\", \"%2F\", \"%3F\", \"%3A\", \"%40\", \"%26\", \"%3D\", \"%2B\", \"%24\", \"%2C\"];\nuriReserved_ = [\";\", \"/\", \"?\", \":\", \"@\", \"&\", \"=\", \"+\", \"$\", \",\"]; \nfor (indexC = 0; indexC < 10; indexC++) { \n var str = uriReserved_[indexC];\n if (encodeURIComponent(str) !== uriReserved[indexC]) {\n $ERROR('#' + (indexC + 1) + ': unescapedURIComponentSet not containing' + str);\n } \n}\n",
+ "id": "S15.1.3.4_A3.1_T1"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Complex tests, uriUnescaped :: uriAlpha",
+ "test": "uriAlpha = [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\", \"K\", \"L\", \"M\", \"N\", \"O\", \"P\", \"Q\", \"R\", \"S\", \"T\", \"U\", \"V\", \"W\", \"X\", \"Y\", \"Z\", \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\"];\nfor (indexC = 0; indexC < uriAlpha.length; indexC++) {\n var str = uriAlpha[indexC]; \n if (encodeURIComponent(str) !== str) {\n $ERROR('#' + (indexC + 1) + ': unescapedURISet containing ' + str);\n } \n}\n",
+ "id": "S15.1.3.4_A3.2_T1"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Complex tests, uriUnescaped :: DecimalDigit",
+ "test": "DecimalDigit = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"];\nfor (indexC = 0; indexC < DecimalDigit.length; indexC++) {\n var str = DecimalDigit[indexC]; \n if (encodeURIComponent(str) !== str) {\n $ERROR('#' + (indexC + 1) + ': unescapedURISet containing' + str);\n } \n}\n",
+ "id": "S15.1.3.4_A3.2_T2"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Complex tests, uriUnescaped :: uriMark",
+ "test": "uriMark = [\"-\", \"_\", \".\", \"!\", \"~\", \"*\", \"'\", \"(\", \")\"];\nfor (indexC = 0; indexC < uriMark.length; indexC++) {\n var str = uriMark[indexC]; \n if (encodeURIComponent(str) !== str) {\n $ERROR('#' + (indexC + 1) + ': unescapedURISet containing' + str);\n } \n}\n",
+ "id": "S15.1.3.4_A3.2_T3"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "encodeURIComponent(\"#\") === \"%23\"",
+ "test": "if (encodeURIComponent(\"#\") !== \"%23\") {\n $ERROR('#1: unescapedURIComponentSet not containing \"%23\"');\n} \n",
+ "id": "S15.1.3.4_A3.3_T1"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Checking ENGLISH ALPHABET",
+ "test": "//CHECK#1\nif (encodeURIComponent(\"http://unipro.ru/0123456789\") !== \"http%3A%2F%2Funipro.ru%2F0123456789\") {\n $ERROR('#1: http://unipro.ru/0123456789');\n}\n\n//CHECK#2\nif (encodeURIComponent(\"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") !== \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") {\n $ERROR('#2: aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ');\n}\n\n//CHECK#3\nif (encodeURIComponent(\";/?:@&=+$,\") !== \"%3B%2F%3F%3A%40%26%3D%2B%24%2C\") {\n $ERROR('#3: ');\n}\n",
+ "id": "S15.1.3.4_A4_T1"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Checking RUSSIAN ALPHABET",
+ "test": "//CHECK#1\nif ((encodeURIComponent(\"http://ru.wikipedia.org/wiki/Юникод\") !== \"http%3A%2F%2Fru.wikipedia.org%2Fwiki%2F%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4\") && (encodeURIComponent(\"http://ru.wikipedia.org/wiki/Юникод\") !== \"http%3A%2F%2Fru.wikipedia.org%2Fwiki%2F\" + \"%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4\".toLowerCase())) {\n $ERROR('#1: http://ru.wikipedia.org/wiki/Юникод');\n}\n\n//CHECK#2\nif ((encodeURIComponent(\"http://ru.wikipedia.org/wiki/Юникод#Ссылки\") !== \"http%3A%2F%2Fru.wikipedia.org%2Fwiki%2F%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4%23%D0%A1%D1%81%D1%8B%D0%BB%D0%BA%D0%B8\") && (encodeURIComponent(\"http://ru.wikipedia.org/wiki/Юникод#Ссылки\") !== \"http%3A%2F%2Fru.wikipedia.org%2Fwiki%2F\" + \"%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4%23%D0%A1%D1%81%D1%8B%D0%BB%D0%BA%D0%B8\".toLowerCase())) {\n $ERROR('#2: http://ru.wikipedia.org/wiki/Юникод#Ссылки');\n}\n\n//CHECK#3\nif ((encodeURIComponent(\"http://ru.wikipedia.org/wiki/Юникод#Версии Юникода\") !== \"http%3A%2F%2Fru.wikipedia.org%2Fwiki%2F%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4%23%D0%92%D0%B5%D1%80%D1%81%D0%B8%D0%B8%20%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4%D0%B0\") && ((encodeURIComponent(\"http://ru.wikipedia.org/wiki/Юникод%23Версии Юникода\") !== \"http%3A%2F%2Fru.wikipedia.org%2Fwiki%2F\" + \"%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4#%D0%92%D0%B5%D1%80%D1%81%D0%B8%D0%B8%20%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4%D0%B0\".toLowerCase()))) {\n $ERROR('#3: http://ru.wikipedia.org/wiki/Юникод#Версии Юникода');\n}\n",
+ "id": "S15.1.3.4_A4_T2"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Checking URL with Line Terminator",
+ "test": "//CHECK#1\nif ((encodeURIComponent(\"http://unipro.ru/\\nabout\") !== \"http%3A%2F%2Funipro.ru%2F%0Aabout\") && encodeURIComponent(\"http://unipro.ru/\\nabout\") !== \"http%3A%2F%2Funipro.ru%2F%0aabout\") {\n $ERROR('#1: http://unipro.ru/\\\\nabout');\n}\n\n//CHECK#2\nif ((encodeURIComponent(\"http://unipro.ru/\\vabout\") !== \"http%3A%2F%2Funipro.ru%2F%0Babout\") && encodeURIComponent(\"http://unipro.ru/\\vabout\") !== \"http%3A%2F%2Funipro.ru%2F%0babout\") {\n $ERROR('#2: http://unipro.ru/\\\\vabout');\n}\n\n//CHECK#3\nif ((encodeURIComponent(\"http://unipro.ru/\\fabout\") !== \"http%3A%2F%2Funipro.ru%2F%0Cabout\") && encodeURIComponent(\"http://unipro.ru/\\fabout\") !== \"http%3A%2F%2Funipro.ru%2F%0cabout\") {\n $ERROR('#3: http://unipro.ru/\\\\fabout');\n}\n\n//CHECK#4\nif ((encodeURIComponent(\"http://unipro.ru/\\rabout\") !== \"http%3A%2F%2Funipro.ru%2F%0Dabout\") && encodeURIComponent(\"http://unipro.ru/\\rabout\") !== \"http%3A%2F%2Funipro.ru%2F%0dabout\") {\n $ERROR('#4: http://unipro.ru/\\\\rabout');\n}\n",
+ "id": "S15.1.3.4_A4_T3"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Test some url",
+ "test": "//CHECK#1\nif (encodeURIComponent(\"\") !== \"\") {\n $ERROR('#1: \"\"');\n}\n\n//CHECK#2\nif (encodeURIComponent(\"http://unipro.ru\") !== \"http%3A%2F%2Funipro.ru\") {\n $ERROR('#2: http://unipro.ru');\n}\n\n//CHECK#3\nif (encodeURIComponent(\"http://www.google.ru/support/jobs/bin/static.py?page=why-ru.html&sid=liveandwork\") !== \"http%3A%2F%2Fwww.google.ru%2Fsupport%2Fjobs%2Fbin%2Fstatic.py%3Fpage%3Dwhy-ru.html%26sid%3Dliveandwork\") {\n $ERROR('#3: http://www.google.ru/support/jobs/bin/static.py?page=why-ru.html&sid=liveandwork\"');\n} \n\n//CHECK#4\nif (encodeURIComponent(\"http://en.wikipedia.org/wiki/UTF-8#Description\") !== \"http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FUTF-8%23Description\") {\n $ERROR('#4: http://en.wikipedia.org/wiki/UTF-8#Description');\n}\n",
+ "id": "S15.1.3.4_A4_T4"
+ },
+ {
+ "section": "15.1.3.4, 15.2.4.7, 12.6.4",
+ "description": "Checking use propertyIsEnumerable, for-in",
+ "test": "//CHECK#1\nif (encodeURIComponent.propertyIsEnumerable('length') !== false) {\n $ERROR('#1: encodeURIComponent.propertyIsEnumerable(\\'length\\') === false. Actual: ' + (encodeURIComponent.propertyIsEnumerable('length')));\n}\n\n//CHECK#2\nresult = true;\nfor (p in encodeURIComponent){\n if (p === \"length\") {\n result = false;\n } \n}\n\nif (result !== true) {\n $ERROR('#2: result = true; for (p in encodeURIComponent) { if (p === \"length\") result = false; } result === true;');\n}\n",
+ "id": "S15.1.3.4_A5.1"
+ },
+ {
+ "section": "15.1.3.4, 15.2.4.5, 11.4.1",
+ "description": "Checking use hasOwnProperty, delete",
+ "test": "//CHECK#1\nif (encodeURIComponent.hasOwnProperty('length') !== true) {\n $FAIL('#1: encodeURIComponent.hasOwnProperty(\\'length\\') === true. Actual: ' + (encodeURIComponent.hasOwnProperty('length')));\n}\n\ndelete encodeURIComponent.length;\n\n//CHECK#2\nif (encodeURIComponent.hasOwnProperty('length') !== true) {\n $ERROR('#2: delete encodeURIComponent.length; encodeURIComponent.hasOwnProperty(\\'length\\') === true. Actual: ' + (encodeURIComponent.hasOwnProperty('length')));\n}\n\n//CHECK#3\nif (encodeURIComponent.length === undefined) {\n $ERROR('#3: delete encodeURIComponent.length; encodeURIComponent.length !== undefined');\n}\n\n\n\n",
+ "id": "S15.1.3.4_A5.2"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Checking if varying the length property fails",
+ "test": "//CHECK#1\nx = encodeURIComponent.length;\nencodeURIComponent.length = Infinity;\nif (encodeURIComponent.length !== x) {\n $ERROR('#1: x = encodeURIComponent.length; encodeURIComponent.length = Infinity; encodeURIComponent.length === x. Actual: ' + (encodeURIComponent.length));\n}\n\n",
+ "id": "S15.1.3.4_A5.3"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "encodeURIComponent.length === 1",
+ "test": "//CHECK#1\nif (encodeURIComponent.length !== 1) {\n $ERROR('#1: encodeURIComponent.length === 1. Actual: ' + (encodeURIComponent.length));\n} \n\n",
+ "id": "S15.1.3.4_A5.4"
+ },
+ {
+ "section": "15.1.3.4, 15.2.4.7, 12.6.4",
+ "description": "Checking use propertyIsEnumerable, for-in",
+ "test": "//CHECK#1\nif (this.propertyIsEnumerable('encodeURIComponent') !== false) {\n $ERROR('#1: this.propertyIsEnumerable(\\'encodeURIComponent\\') === false. Actual: ' + (this.propertyIsEnumerable('encodeURIComponent')));\n}\n\n//CHECK#2\nresult = true;\nfor (p in this){\n if (p === \"encodeURIComponent\") {\n result = false;\n } \n}\n\nif (result !== true) {\n $ERROR('#2: result = true; for (p in this) { if (p === \"encodeURIComponent\") result = false; } result === true;');\n}\n",
+ "id": "S15.1.3.4_A5.5"
+ },
+ {
+ "section": "15.1.3.4",
+ "description": "Checking encodeURIComponent.prototype",
+ "test": "//CHECK#1\nif (encodeURIComponent.prototype !== undefined) {\n $ERROR('#1: encodeURIComponent.prototype === undefined. Actual: ' + (encodeURIComponent.prototype));\n}\n",
+ "id": "S15.1.3.4_A5.6"
+ },
+ {
+ "section": "15.1.3.4, 11.2.2",
+ "description": "If property does not implement the internal [[Construct]] method, throw a TypeError exception",
+ "test": "//CHECK#1\n\ntry {\n new encodeURIComponent();\n $ERROR('#1.1: new encodeURIComponent() throw TypeError. Actual: ' + (new encodeURIComponent()));\n} catch (e) {\n if ((e instanceof TypeError) !== true) {\n $ERROR('#1.2: new encodeURIComponent() throw TypeError. Actual: ' + (e));\n }\n}\n",
+ "id": "S15.1.3.4_A5.7"
+ },
+ {
+ "section": "15.1.3.4, 9.8, 8.6.2.6",
+ "description": "If Type(value) is Object, evaluate ToPrimitive(value, String)",
+ "test": "//CHECK#1\nvar object = {valueOf: function() {return \"^\"}};\nif (encodeURIComponent(object) !== \"%5Bobject%20Object%5D\") {\n $ERROR('#1: var object = {valueOf: function() {return \"^\"}}; encodeURIComponent(object) === %5Bobject%20Object%5D. Actual: ' + (encodeURIComponent(object)));\n}\n\n//CHECK#2\nvar object = {valueOf: function() {return \"\"}, toString: function() {return \"^\"}};\nif (encodeURIComponent(object) !== \"%5E\") {\n $ERROR('#2: var object = {valueOf: function() {return \"\"}, toString: function() {return \"^\"}}; encodeURIComponent(object) === \"%5E\". Actual: ' + (encodeURIComponent(object)));\n} \n\n//CHECK#3\nvar object = {valueOf: function() {return \"^\"}, toString: function() {return {}}};\nif (encodeURIComponent(object) !== \"%5E\") {\n $ERROR('#3: var object = {valueOf: function() {return \"^\"}, toString: function() {return {}}}; encodeURIComponent(object) === \"%5E\". Actual: ' + (encodeURIComponent(object)));\n}\n\n//CHECK#4\ntry {\n var object = {valueOf: function() {throw \"error\"}, toString: function() {return \"^\"}};\n if (encodeURIComponent(object) !== \"%5E\") {\n $ERROR('#4.1: var object = {valueOf: function() {throw \"error\"}, toString: function() {return \"^\"}}; encodeURIComponent(object) === \"%5E\". Actual: ' + (encodeURIComponent(object)));\n }\n}\ncatch (e) {\n if (e === \"error\") {\n $ERROR('#4.2: var object = {valueOf: function() {throw \"error\"}, toString: function() {return \"^\"}}; encodeURIComponent(object) not throw \"error\"');\n } else {\n $ERROR('#4.3: var object = {valueOf: function() {throw \"error\"}, toString: function() {return \"^\"}}; encodeURIComponent(object) not throw Error. Actual: ' + (e));\n }\n}\n\n//CHECK#5\nvar object = {toString: function() {return \"^\"}};\nif (encodeURIComponent(object) !== \"%5E\") {\n $ERROR('#5: var object = {toString: function() {return \"^\"}}; encodeURIComponent(object) === \"%5E\". Actual: ' + (encodeURIComponent(object)));\n}\n\n//CHECK#6\nvar object = {valueOf: function() {return {}}, toString: function() {return \"^\"}}\nif (encodeURIComponent(object) !== \"%5E\") {\n $ERROR('#6: var object = {valueOf: function() {return {}}, toString: function() {return \"^\"}}; encodeURIComponent(object) === \"%5E\". Actual: ' + (encodeURIComponent(object)));\n}\n\n//CHECK#7\ntry {\n var object = {valueOf: function() {return \"^\"}, toString: function() {throw \"error\"}};\n encodeURIComponent(object);\n $ERROR('#7.1: var object = {valueOf: function() {return \"^\"}, toString: function() {throw \"error\"}}; encodeURIComponent(object) throw \"error\". Actual: ' + (encodeURIComponent(object)));\n} \ncatch (e) {\n if (e !== \"error\") {\n $ERROR('#7.2: var object = {valueOf: function() {return \"^\"}, toString: function() {throw \"error\"}}; encodeURIComponent(object) throw \"error\". Actual: ' + (e));\n } \n}\n\n//CHECK#8\ntry {\n var object = {valueOf: function() {return {}}, toString: function() {return {}}};\n encodeURIComponent(object);\n $ERROR('#8.1: var object = {valueOf: function() {return {}}, toString: function() {return {}}}; encodeURIComponent(object) throw TypeError. Actual: ' + (encodeURIComponent(object)));\n} \ncatch (e) {\n if ((e instanceof TypeError) !== true) {\n $ERROR('#8.2: var object = {valueOf: function() {return {}}, toString: function() {return {}}}; encodeURIComponent(object) throw TypeError. Actual: ' + (e));\n } \n}\n",
+ "id": "S15.1.3.4_A6_T1"
+ }
+ ]
+ }
+}