Platform-DOM-Tests.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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.innerEval = function (expr) { return eval(expr); };
  5. $pkg.transport = {"type":"amd","amdNamespace":"amber/core"};
  6. $core.addClass("PlatformDomTest", $globals.TestCase, ["fixtureDiv"], "Platform-DOM-Tests");
  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. var $1;
  24. $1=$recv($globals.PlatformDom)._isFeasible();
  25. if($core.assert($1)){
  26. $self._assert_equals_("©"._htmlTextContent(),"©");
  27. }
  28. return self;
  29. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  30. }, function($ctx1) {$ctx1.fill(self,"testEntityConversion",{})});
  31. //>>excludeEnd("ctx");
  32. }; }),
  33. $globals.PlatformDomTest);
  34. $core.addMethod(
  35. $core.method({
  36. selector: "testTextContentDoesNotRunScript",
  37. protocol: "testing",
  38. //>>excludeStart("ide", pragmas.excludeIdeData);
  39. args: [],
  40. source: "testTextContentDoesNotRunScript\x0a\x09PlatformDom isFeasible ifTrue: [\x0a\x09\x09self shouldnt: [ '<script>throw new Error(\x22Intentional\x22)</script>' htmlTextContent ] raise: Error ]",
  41. referencedClasses: ["PlatformDom", "Error"],
  42. //>>excludeEnd("ide");
  43. pragmas: [],
  44. messageSends: ["ifTrue:", "isFeasible", "shouldnt:raise:", "htmlTextContent"]
  45. }, function ($methodClass){ return function (){
  46. var self=this,$self=this;
  47. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  48. return $core.withContext(function($ctx1) {
  49. //>>excludeEnd("ctx");
  50. var $1;
  51. $1=$recv($globals.PlatformDom)._isFeasible();
  52. if($core.assert($1)){
  53. $self._shouldnt_raise_((function(){
  54. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  55. return $core.withContext(function($ctx2) {
  56. //>>excludeEnd("ctx");
  57. return "<script>throw new Error(\x22Intentional\x22)</script>"._htmlTextContent();
  58. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  59. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  60. //>>excludeEnd("ctx");
  61. }),$globals.Error);
  62. }
  63. return self;
  64. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  65. }, function($ctx1) {$ctx1.fill(self,"testTextContentDoesNotRunScript",{})});
  66. //>>excludeEnd("ctx");
  67. }; }),
  68. $globals.PlatformDomTest);
  69. });