19258b6bc66e09368ada54001f619d53b4fc976d5ager@chromium.org// Copyright 2008 the V8 project authors. All rights reserved. 29a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Redistribution and use in source and binary forms, with or without 39a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// modification, are permitted provided that the following conditions are 49a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// met: 59a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// 69a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// * Redistributions of source code must retain the above copyright 79a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// notice, this list of conditions and the following disclaimer. 89a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// * Redistributions in binary form must reproduce the above 99a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// copyright notice, this list of conditions and the following 109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// disclaimer in the documentation and/or other materials provided 119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// with the distribution. 129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// * Neither the name of Google Inc. nor the names of its 139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// contributors may be used to endorse or promote products derived 149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// from this software without specific prior written permission. 159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// 169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Tests of URI encoding and decoding. 299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.!~*'();/?:@&=+$,#", 319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com encodeURI("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.!~*'();/?:@&=+$,#")); 329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar cc1 = 0x007D; 349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar s1 = String.fromCharCode(cc1); 359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar cc2 = 0x0000; 369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar s2 = String.fromCharCode(cc2); 379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar cc3 = 0x0080; 389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar s3 = String.fromCharCode(cc3); 399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar cc4 = 0x0555; 409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar s4 = String.fromCharCode(cc4); 419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar cc5 = 0x07FF; 429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar s5 = String.fromCharCode(cc5); 439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar cc6 = 0x0800; 449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar s6 = String.fromCharCode(cc6); 459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar cc7 = 0xAEEE; 469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar s7 = String.fromCharCode(cc7); 479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar cc8_1 = 0xD800; 489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar cc8_2 = 0xDC00; 499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar s8 = String.fromCharCode(cc8_1)+String.fromCharCode(cc8_2); 509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar cc9_1 = 0xDBFF; 519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar cc9_2 = 0xDFFF; 529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar s9 = String.fromCharCode(cc9_1)+String.fromCharCode(cc9_2); 539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar cc10 = 0xE000; 549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar s10 = String.fromCharCode(cc10); 559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('%7D', encodeURI(s1)); 579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('%00', encodeURI(s2)); 589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('%C2%80', encodeURI(s3)); 599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('%D5%95', encodeURI(s4)); 609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('%DF%BF', encodeURI(s5)); 619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('%E0%A0%80', encodeURI(s6)); 629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('%EA%BB%AE', encodeURI(s7)); 639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('%F0%90%80%80', encodeURI(s8)); 649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('%F4%8F%BF%BF', encodeURI(s9)); 659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('%EE%80%80', encodeURI(s10)); 669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(cc1, decodeURI(encodeURI(s1)).charCodeAt(0)); 689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(cc2, decodeURI(encodeURI(s2)).charCodeAt(0)); 699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(cc3, decodeURI(encodeURI(s3)).charCodeAt(0)); 709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(cc4, decodeURI(encodeURI(s4)).charCodeAt(0)); 719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(cc5, decodeURI(encodeURI(s5)).charCodeAt(0)); 729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(cc6, decodeURI(encodeURI(s6)).charCodeAt(0)); 739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(cc7, decodeURI(encodeURI(s7)).charCodeAt(0)); 749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(cc8_1, decodeURI(encodeURI(s8)).charCodeAt(0)); 759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(cc8_2, decodeURI(encodeURI(s8)).charCodeAt(1)); 769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(cc9_1, decodeURI(encodeURI(s9)).charCodeAt(0)); 779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(cc9_2, decodeURI(encodeURI(s9)).charCodeAt(1)); 789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(cc10, decodeURI(encodeURI(s10)).charCodeAt(0)); 7932280cf2786219b2d9a668f7f00778fb59ac40b3mstarzinger@chromium.org 8032280cf2786219b2d9a668f7f00778fb59ac40b3mstarzinger@chromium.orgassertEquals("", decodeURI("")); 8132280cf2786219b2d9a668f7f00778fb59ac40b3mstarzinger@chromium.orgassertEquals("", encodeURI("")); 8232280cf2786219b2d9a668f7f00778fb59ac40b3mstarzinger@chromium.org 8332280cf2786219b2d9a668f7f00778fb59ac40b3mstarzinger@chromium.orgfunction test(string) { 8432280cf2786219b2d9a668f7f00778fb59ac40b3mstarzinger@chromium.org assertEquals(string, decodeURI(encodeURI(string))); 8532280cf2786219b2d9a668f7f00778fb59ac40b3mstarzinger@chromium.org} 8632280cf2786219b2d9a668f7f00778fb59ac40b3mstarzinger@chromium.org 8732280cf2786219b2d9a668f7f00778fb59ac40b3mstarzinger@chromium.orgtest("\u1234\u0123\uabcd"); 8832280cf2786219b2d9a668f7f00778fb59ac40b3mstarzinger@chromium.orgtest("abcd"); 8932280cf2786219b2d9a668f7f00778fb59ac40b3mstarzinger@chromium.orgtest("ab<\u1234\u0123"); 9032280cf2786219b2d9a668f7f00778fb59ac40b3mstarzinger@chromium.orgtest("ab\u1234<\u0123"); 91