PageRenderTime 61ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

/test/acceptance/ecma3/GlobalObject/decodeURIComponent.as

https://github.com/changm/tessa
ActionScript | 122 lines | 58 code | 28 blank | 36 comment | 0 complexity | 4910dc01cea7040dbfda6b074bfd9029 MD5 | raw file
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/MPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * The Original Code is [Open Source Virtual Machine.].
  15. *
  16. * The Initial Developer of the Original Code is
  17. * Adobe System Incorporated.
  18. * Portions created by the Initial Developer are Copyright (C) 2005-2006
  19. * the Initial Developer. All Rights Reserved.
  20. *
  21. * Contributor(s):
  22. * Adobe AS3 Team
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. var SECTION = "15.1.3.2";
  38. var VERSION = "ECMA_1";
  39. startTest();
  40. var TITLE = "decodeURIComponent";
  41. writeHeaderToLog( SECTION + " "+ TITLE);
  42. var testcases = getTestCases();
  43. test();
  44. function getTestCases() {
  45. var array:Array = new Array();
  46. var item:Number= 0;
  47. var str1:String = new String("h");
  48. array[item++] = new TestCase( SECTION, "decodeURIComponent('Hello%7B%5BWorld%5D%7D')", "Hello{[World]}", decodeURIComponent("Hello%7B%5BWorld%5D%7D") );
  49. array[item++] = new TestCase( SECTION, "decodeURIComponent('Macromedia%20-%20Flash')", "Macromedia - Flash", decodeURIComponent("Macromedia%20-%20Flash") );
  50. array[item++] = new TestCase( SECTION, "decodeURIComponent('2%20*%204%20%2B%20%5B8%20%2B%205%20%5D%20-%203')", "2 * 4 + [8 + 5 ] - 3", decodeURIComponent("2%20*%204%20%2B%20%5B8%20%2B%205%20%5D%20-%203") );
  51. array[item++] = new TestCase( SECTION, "decodeURIComponent('Flash(Macromedia)')", "Flash(Macromedia)", decodeURIComponent("Flash(Macromedia)") );
  52. array[item++] = new TestCase( SECTION, "decodeURIComponent('BugID%20%2317485')", "BugID #17485", decodeURIComponent("BugID%20%2317485") );
  53. array[item++] = new TestCase( SECTION, "decodeURIComponent('http%3A%2F%2Fwww.macromedia.com%2Fflasha%20player')", "http://www.macromedia.com/flasha player", decodeURIComponent("http%3A%2F%2Fwww.macromedia.com%2Fflasha%20player") );
  54. array[item++] = new TestCase( SECTION, "decodeURIComponent('http%3A%2F%2Fwww.macromedia.com%2FflashA%20player')", "http://www.macromedia.com/flashA player", decodeURIComponent("http%3A%2F%2Fwww.macromedia.com%2FflashA%20player") );
  55. array[item++] = new TestCase( SECTION, "decodeURIComponent('http%3A%2F%2Fwww.macromedia.com%2Fflash_%20player')", "http://www.macromedia.com/flash_ player", decodeURIComponent("http%3A%2F%2Fwww.macromedia.com%2Fflash_%20player") );
  56. array[item++] = new TestCase( SECTION, "decodeURIComponent('http%3A%2F%2Fwww.macromedia.com%2Fflash-%20player')", "http://www.macromedia.com/flash- player", decodeURIComponent("http%3A%2F%2Fwww.macromedia.com%2Fflash-%20player") );
  57. array[item++] = new TestCase( SECTION, "decodeURIComponent('http%3A%2F%2Fwww.macromedia.com%2Fflash.%20player')", "http://www.macromedia.com/flash. player", decodeURIComponent("http%3A%2F%2Fwww.macromedia.com%2Fflash.%20player") );
  58. array[item++] = new TestCase( SECTION, "decodeURIComponent('http%3A%2F%2Fwww.macromedia.com%2Fflash!%20player')", "http://www.macromedia.com/flash! player", decodeURIComponent("http%3A%2F%2Fwww.macromedia.com%2Fflash!%20player") );
  59. array[item++] = new TestCase( SECTION, "decodeURIComponent('http%3A%2F%2Fwww.macromedia.com%2Fflash~%20player')", "http://www.macromedia.com/flash~ player", decodeURIComponent("http%3A%2F%2Fwww.macromedia.com%2Fflash~%20player") );
  60. array[item++] = new TestCase( SECTION, "decodeURIComponent('http%3A%2F%2Fwww.macromedia.com%2Fflash*%20player')", "http://www.macromedia.com/flash* player", decodeURIComponent("http%3A%2F%2Fwww.macromedia.com%2Fflash*%20player") );
  61. array[item++] = new TestCase( SECTION, "decodeURIComponent('http%3A%2F%2Fwww.macromedia.com%2F'flash%20player'')", "http://www.macromedia.com/'flash player'", decodeURIComponent("http%3A%2F%2Fwww.macromedia.com%2F'flash%20player'") );
  62. array[item++] = new TestCase( SECTION, "decodeURIComponent('http%3A%2F%2Fwww.macromedia.com%2F(flash%20player)')", "http://www.macromedia.com/(flash player)", decodeURIComponent("http%3A%2F%2Fwww.macromedia.com%2F(flash%20player)") );
  63. array[item++] = new TestCase( SECTION, "decodeURIComponent('http%3A%2F%2Fwww.macromedia.com%2Fflash%3B%20player')", "http://www.macromedia.com/flash; player", decodeURIComponent("http%3A%2F%2Fwww.macromedia.com%2Fflash%3B%20player")+"" );
  64. array[item++] = new TestCase( SECTION, "decodeURIComponent('http%3A%2F%2Fwww.macromedia.com%2Fflash%20player%3F')", "http://www.macromedia.com/flash player?", decodeURIComponent("http%3A%2F%2Fwww.macromedia.com%2Fflash%20player%3F")+"" );
  65. array[item++] = new TestCase( SECTION, "decodeURIComponent('http%3A%2F%2Fwww.macromedia.com%2Fflash%20player%40')", "http://www.macromedia.com/flash player@", decodeURIComponent("http%3A%2F%2Fwww.macromedia.com%2Fflash%20player%40")+"" );
  66. array[item++] = new TestCase( SECTION, "decodeURIComponent('http%3A%2F%2Fwww.macromedia.com%2Fflash%20player%26')", "http://www.macromedia.com/flash player&", decodeURIComponent("http%3A%2F%2Fwww.macromedia.com%2Fflash%20player%26")+"" );
  67. array[item++] = new TestCase( SECTION, "decodeURIComponent('http%3A%2F%2Fwww.macromedia.com%2Fflash%20player%3D')", "http://www.macromedia.com/flash player=", decodeURIComponent("http%3A%2F%2Fwww.macromedia.com%2Fflash%20player%3D")+"" );
  68. array[item++] = new TestCase( SECTION, "decodeURIComponent('http%3A%2F%2Fwww.macromedia.com%2Fflash%20player%24')", "http://www.macromedia.com/flash player$", decodeURIComponent("http%3A%2F%2Fwww.macromedia.com%2Fflash%20player%24")+"" );
  69. var thisError:String = 'no exception';
  70. try{
  71. decodeURIComponent('http://www.macromedia.com/flash%GKplayer')
  72. }catch(e:Error){
  73. thisError=(e.toString()).substring(0,8);
  74. }finally{
  75. array[item++] = new TestCase( SECTION, "Characters following % should be hexa decimal digits", "URIError", thisError);
  76. }
  77. thisError = 'no exception';
  78. try{
  79. decodeURIComponent('http://www.macromedia.com/flash%20player%')
  80. }catch(e1:Error){
  81. thisError=(e1.toString()).substring(0,8);
  82. }finally{
  83. array[item++] = new TestCase( SECTION, "If the last character of string is % throw URIError", "URIError", thisError);
  84. }
  85. thisError = 'no exception';
  86. try{
  87. decodeURIComponent('http://www.macromedia.com/flash5%2player')
  88. }catch(e2:Error){
  89. thisError=(e2.toString()).substring(0,8);
  90. }finally{
  91. array[item++] = new TestCase( SECTION, "If the character at position k of string before hexadecimal digits is not % throw URIError", "URIError", thisError);
  92. }
  93. return ( array );
  94. }