1
0

Platform-DOM-Tests.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. define(["amber/boot", "amber_core/SUnit"], function($boot){"use strict";
  2. if(!$boot.nilAsReceiver)$boot.nilAsReceiver=$boot.nil;
  3. var $core=$boot.api,nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  4. if(!$boot.nilAsClass)$boot.nilAsClass=$boot.dnu;
  5. $core.addPackage('Platform-DOM-Tests');
  6. $core.packages["Platform-DOM-Tests"].innerEval = function (expr) { return eval(expr); };
  7. $core.packages["Platform-DOM-Tests"].transport = {"type":"amd","amdNamespace":"amber_core"};
  8. $core.addClass('PlatformDomTest', $globals.TestCase, ['fixtureDiv'], 'Platform-DOM-Tests');
  9. $core.addMethod(
  10. $core.method({
  11. selector: "testEntityConversion",
  12. protocol: 'testing',
  13. fn: function (){
  14. var self=this;
  15. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  16. return $core.withContext(function($ctx1) {
  17. //>>excludeEnd("ctx");
  18. var $1;
  19. $1=$recv($globals.PlatformDom)._isFeasible();
  20. if($core.assert($1)){
  21. self._assert_equals_("©"._htmlTextContent(),"©");
  22. }
  23. return self;
  24. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  25. }, function($ctx1) {$ctx1.fill(self,"testEntityConversion",{},$globals.PlatformDomTest)});
  26. //>>excludeEnd("ctx");
  27. },
  28. //>>excludeStart("ide", pragmas.excludeIdeData);
  29. args: [],
  30. source: "testEntityConversion\x0a\x09PlatformDom isFeasible ifTrue: [ self assert: '©' htmlTextContent equals: '©' ]",
  31. referencedClasses: ["PlatformDom"],
  32. //>>excludeEnd("ide");
  33. messageSends: ["ifTrue:", "isFeasible", "assert:equals:", "htmlTextContent"]
  34. }),
  35. $globals.PlatformDomTest);
  36. $core.addMethod(
  37. $core.method({
  38. selector: "testTextContentDoesNotRunScript",
  39. protocol: 'testing',
  40. fn: function (){
  41. var self=this;
  42. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  43. return $core.withContext(function($ctx1) {
  44. //>>excludeEnd("ctx");
  45. var $1;
  46. $1=$recv($globals.PlatformDom)._isFeasible();
  47. if($core.assert($1)){
  48. self._shouldnt_raise_((function(){
  49. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  50. return $core.withContext(function($ctx2) {
  51. //>>excludeEnd("ctx");
  52. return "<script>throw new Error(\x22Intentional\x22)</script>"._htmlTextContent();
  53. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  54. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  55. //>>excludeEnd("ctx");
  56. }),$globals.Error);
  57. }
  58. return self;
  59. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  60. }, function($ctx1) {$ctx1.fill(self,"testTextContentDoesNotRunScript",{},$globals.PlatformDomTest)});
  61. //>>excludeEnd("ctx");
  62. },
  63. //>>excludeStart("ide", pragmas.excludeIdeData);
  64. args: [],
  65. source: "testTextContentDoesNotRunScript\x0a\x09PlatformDom isFeasible ifTrue: [\x0a\x09\x09self shouldnt: [ '<script>throw new Error(\x22Intentional\x22)</script>' htmlTextContent ] raise: Error ]",
  66. referencedClasses: ["PlatformDom", "Error"],
  67. //>>excludeEnd("ide");
  68. messageSends: ["ifTrue:", "isFeasible", "shouldnt:raise:", "htmlTextContent"]
  69. }),
  70. $globals.PlatformDomTest);
  71. });