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. fn: function (){
  12. var self=this,$self=this;
  13. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  14. return $core.withContext(function($ctx1) {
  15. //>>excludeEnd("ctx");
  16. var $1;
  17. $1=$recv($globals.PlatformDom)._isFeasible();
  18. if($core.assert($1)){
  19. $self._assert_equals_("©"._htmlTextContent(),"©");
  20. }
  21. return self;
  22. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  23. }, function($ctx1) {$ctx1.fill(self,"testEntityConversion",{},$globals.PlatformDomTest)});
  24. //>>excludeEnd("ctx");
  25. },
  26. //>>excludeStart("ide", pragmas.excludeIdeData);
  27. args: [],
  28. source: "testEntityConversion\x0a\x09PlatformDom isFeasible ifTrue: [ self assert: '©' htmlTextContent equals: '©' ]",
  29. referencedClasses: ["PlatformDom"],
  30. //>>excludeEnd("ide");
  31. messageSends: ["ifTrue:", "isFeasible", "assert:equals:", "htmlTextContent"]
  32. }),
  33. $globals.PlatformDomTest);
  34. $core.addMethod(
  35. $core.method({
  36. selector: "testTextContentDoesNotRunScript",
  37. protocol: "testing",
  38. fn: function (){
  39. var self=this,$self=this;
  40. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  41. return $core.withContext(function($ctx1) {
  42. //>>excludeEnd("ctx");
  43. var $1;
  44. $1=$recv($globals.PlatformDom)._isFeasible();
  45. if($core.assert($1)){
  46. $self._shouldnt_raise_((function(){
  47. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  48. return $core.withContext(function($ctx2) {
  49. //>>excludeEnd("ctx");
  50. return "<script>throw new Error(\x22Intentional\x22)</script>"._htmlTextContent();
  51. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  52. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  53. //>>excludeEnd("ctx");
  54. }),$globals.Error);
  55. }
  56. return self;
  57. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  58. }, function($ctx1) {$ctx1.fill(self,"testTextContentDoesNotRunScript",{},$globals.PlatformDomTest)});
  59. //>>excludeEnd("ctx");
  60. },
  61. //>>excludeStart("ide", pragmas.excludeIdeData);
  62. args: [],
  63. source: "testTextContentDoesNotRunScript\x0a\x09PlatformDom isFeasible ifTrue: [\x0a\x09\x09self shouldnt: [ '<script>throw new Error(\x22Intentional\x22)</script>' htmlTextContent ] raise: Error ]",
  64. referencedClasses: ["PlatformDom", "Error"],
  65. //>>excludeEnd("ide");
  66. messageSends: ["ifTrue:", "isFeasible", "shouldnt:raise:", "htmlTextContent"]
  67. }),
  68. $globals.PlatformDomTest);
  69. });