|
483 | 483 | document.body.appendChild(iframe); |
484 | 484 | var iDoc = (iDoc = iframe.contentDocument || iframe.contentWindow).document || iDoc; |
485 | 485 | iDoc.write( |
486 | | - '<script>' + |
487 | | - ' parent.iElement = document.createElement("div");' + |
488 | | - ' parent.iArguments = (function(){ return arguments; })(1, 2, 3);' + |
489 | | - ' parent.iArray = [1, 2, 3];' + |
490 | | - ' parent.iString = new String("hello");' + |
491 | | - ' parent.iNumber = new Number(100);' + |
492 | | - ' parent.iFunction = (function(){});' + |
493 | | - ' parent.iDate = new Date();' + |
494 | | - ' parent.iRegExp = /hi/;' + |
495 | | - ' parent.iNaN = NaN;' + |
496 | | - ' parent.iNull = null;' + |
497 | | - ' parent.iBoolean = new Boolean(false);' + |
498 | | - ' parent.iUndefined = undefined;' + |
499 | | - ' parent.iObject = {};' + |
500 | | - '</script>' |
| 486 | + '<script>\ |
| 487 | + parent.iElement = document.createElement("div");\ |
| 488 | + parent.iArguments = (function(){ return arguments; })(1, 2, 3);\ |
| 489 | + parent.iArray = [1, 2, 3];\ |
| 490 | + parent.iString = new String("hello");\ |
| 491 | + parent.iNumber = new Number(100);\ |
| 492 | + parent.iFunction = (function(){});\ |
| 493 | + parent.iDate = new Date();\ |
| 494 | + parent.iRegExp = /hi/;\ |
| 495 | + parent.iNaN = NaN;\ |
| 496 | + parent.iNull = null;\ |
| 497 | + parent.iBoolean = new Boolean(false);\ |
| 498 | + parent.iUndefined = undefined;\ |
| 499 | + parent.iObject = {};\ |
| 500 | + parent.iError = new Error();\ |
| 501 | + </script>' |
501 | 502 | ); |
502 | 503 | iDoc.close(); |
503 | 504 |
|
|
638 | 639 | ok(_.isUndefined(iUndefined), 'even from another frame'); |
639 | 640 | }); |
640 | 641 |
|
| 642 | + test('isError', function() { |
| 643 | + ok(!_.isError(1), 'numbers are not Errors'); |
| 644 | + ok(!_.isError(null), 'null is not an Error'); |
| 645 | + ok(!_.isError(Error), 'functions are not Errors'); |
| 646 | + ok(_.isError(new Error()), 'Errors are Errors'); |
| 647 | + ok(_.isError(iError), 'even from another frame'); |
| 648 | + ok(_.isError(new EvalError()), 'EvalErrors are Errors'); |
| 649 | + ok(_.isError(new RangeError()), 'RangeErrors are Errors'); |
| 650 | + ok(_.isError(new ReferenceError()), 'ReferenceErrors are Errors'); |
| 651 | + ok(_.isError(new SyntaxError()), 'SyntaxErrors are Errors'); |
| 652 | + ok(_.isError(new TypeError()), 'TypeErrors are Errors'); |
| 653 | + ok(_.isError(new URIError()), 'URIErrors are Errors'); |
| 654 | + }); |
| 655 | + |
641 | 656 | if (window.ActiveXObject) { |
642 | 657 | test('IE host objects', function() { |
643 | 658 | var xml = new ActiveXObject('Msxml2.DOMDocument.3.0'); |
|
0 commit comments