Platform-DOM-Tests.js 2.7 KB

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