Platform-DOM-Tests.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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, ["fixtureDiv"], "Platform-DOM-Tests");
  6. $core.addMethod(
  7. $core.method({
  8. selector: "testEntityConversion",
  9. protocol: "testing",
  10. //>>excludeStart("ide", pragmas.excludeIdeData);
  11. args: [],
  12. source: "testEntityConversion\x0a\x09PlatformDom isFeasible ifTrue: [ self assert: '©' htmlTextContent equals: '©' ]",
  13. referencedClasses: ["PlatformDom"],
  14. //>>excludeEnd("ide");
  15. pragmas: [],
  16. messageSends: ["ifTrue:", "isFeasible", "assert:equals:", "htmlTextContent"]
  17. }, function ($methodClass){ return function (){
  18. var self=this,$self=this;
  19. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  20. return $core.withContext(function($ctx1) {
  21. //>>excludeEnd("ctx");
  22. if($core.assert($recv($globals.PlatformDom)._isFeasible())){
  23. $self._assert_equals_("©"._htmlTextContent(),"©");
  24. }
  25. return self;
  26. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  27. }, function($ctx1) {$ctx1.fill(self,"testEntityConversion",{})});
  28. //>>excludeEnd("ctx");
  29. }; }),
  30. $globals.PlatformDomTest);
  31. $core.addMethod(
  32. $core.method({
  33. selector: "testTextContentDoesNotRunScript",
  34. protocol: "testing",
  35. //>>excludeStart("ide", pragmas.excludeIdeData);
  36. args: [],
  37. source: "testTextContentDoesNotRunScript\x0a\x09PlatformDom isFeasible ifTrue: [\x0a\x09\x09self shouldnt: [ '<script>throw new Error(\x22Intentional\x22)</script>' htmlTextContent ] raise: Error ]",
  38. referencedClasses: ["PlatformDom", "Error"],
  39. //>>excludeEnd("ide");
  40. pragmas: [],
  41. messageSends: ["ifTrue:", "isFeasible", "shouldnt:raise:", "htmlTextContent"]
  42. }, function ($methodClass){ return function (){
  43. var self=this,$self=this;
  44. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  45. return $core.withContext(function($ctx1) {
  46. //>>excludeEnd("ctx");
  47. if($core.assert($recv($globals.PlatformDom)._isFeasible())){
  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",{})});
  61. //>>excludeEnd("ctx");
  62. }; }),
  63. $globals.PlatformDomTest);
  64. });