| OLD | NEW | 
|   1 <!DOCTYPE html> |   1 <!DOCTYPE html> | 
|   2 <title>[LenientThis] test</title> |   2 <title>[LenientThis] test</title> | 
|   3 <script src="../../resources/testharness.js"></script> |   3 <script src="../../resources/testharness.js"></script> | 
|   4 <script src="../../resources/testharnessreport.js"></script> |   4 <script src="../../resources/testharnessreport.js"></script> | 
|   5 <script> |   5 <script> | 
|   6 test(function() { |   6 test(function() { | 
|   7     // GlobalEventHandlers.onmouseenter is [LenientThis]. |   7   // GlobalEventHandlers.onmouseenter is [LenientThis]. | 
|   8     assert_equals(document.onmouseenter, null, "|this| is an appropriate object.
    "); |   8   assert_equals(document.onmouseenter, null, "|this| is an appropriate object.")
    ; | 
|   9     assert_equals(Document.prototype.onmouseenter, undefined, "|this| is not an 
    appropriate object."); |   9   assert_equals(Document.prototype.onmouseenter, undefined, "|this| is not an ap
    propriate object."); | 
|  10     Document.prototype.onmouseenter = 'foo'; // must not throw. |  10   Document.prototype.onmouseenter = 'foo'; // must not throw. | 
|  11     assert_equals(Document.prototype.onmouseenter, undefined, "the value must no
    t change."); |  11   assert_equals(Document.prototype.onmouseenter, undefined, "the value must not 
    change."); | 
|  12  |  12  | 
|  13     // GlobalEventHandlers.onmousedown is NOT [LenientThis]. |  13   // GlobalEventHandlers.onmousedown is NOT [LenientThis]. | 
|  14     assert_equals(document.onmousedown, null, "|this| is an appropriate object."
    ); |  14   assert_equals(document.onmousedown, null, "|this| is an appropriate object."); | 
|  15     assert_throws(null, function() { |  15   assert_throws(null, function() { | 
|  16         Document.prototype.onmousedown; |  16     Document.prototype.onmousedown; | 
|  17     }, "Document.prototype is invalid as |this|."); |  17   }, "Document.prototype is invalid as |this|."); | 
|  18     assert_throws(null, function() { |  18   assert_throws(null, function() { | 
|  19         Document.prototype.onmousedown = 'foo'; |  19     Document.prototype.onmousedown = 'foo'; | 
|  20     }, "Document.prototype is invalid as |this|."); |  20   }, "Document.prototype is invalid as |this|."); | 
|  21 }); |  21 }, "Test [LenientThis] and non-[LenientThis]."); | 
 |  22  | 
 |  23 test(function() { | 
 |  24   var noop = function() {}; | 
 |  25   var testPatterns = [ | 
 |  26     {name: 'document', instance: document, holder: Document.prototype, noninstan
    ce: window}, | 
 |  27     {name: 'window',  instance: window, holder: window, noninstance: document} | 
 |  28   ]; | 
 |  29   function msg(pattern, text) { | 
 |  30     return '[' + pattern.name + '] ' + text; | 
 |  31   } | 
 |  32   for (var p, i = 0; p = testPatterns[i]; ++i) { | 
 |  33     var pd = Object.getOwnPropertyDescriptor(p.holder, 'onmouseleave'); | 
 |  34     // get | 
 |  35     assert_equals(pd.get.call(p.noninstance), undefined, msg(p, 'get: non-instan
    ce should return undefined.')); | 
 |  36     assert_equals(pd.get.call(p.instance), null, msg(p, 'get: instance should re
    turn null by default.')); | 
 |  37  | 
 |  38     // set | 
 |  39     assert_equals(pd.set.call(p.noninstance, noop), undefined, msg(p, 'set: sett
    er always returns undefined.')); | 
 |  40     assert_equals(pd.get.call(p.noninstance), undefined, msg(p, 'set: non-instan
    ce should returns undefined.')); | 
 |  41     assert_equals(pd.set.call(p.instance, noop), undefined, msg(p, 'set: even in
    stance should return undefined.')); | 
 |  42     assert_equals(pd.get.call(p.instance), noop, msg(p, 'set: instance should re
    turn the assigned function.')); | 
 |  43   } | 
 |  44  | 
 |  45   // document specific tests. | 
 |  46   pd = Object.getOwnPropertyDescriptor(Document.prototype, 'onmouseleave'); | 
 |  47   assert_equals(pd.get.call(null), undefined, '[document] get: null is not a val
    id instance.'); | 
 |  48   assert_equals(pd.get.call(undefined), undefined, '[document] get: undefined is
     not a valid instance.'); | 
 |  49  | 
 |  50   // window specific tests. | 
 |  51   pd = Object.getOwnPropertyDescriptor(window, 'onmouseleave'); | 
 |  52   assert_equals(pd.get.call(null), noop, '[window] get: null should be interpret
    ed as the global object.'); | 
 |  53   assert_equals(pd.get.call(undefined), noop, '[window] get: undefined should be
     interpreted as the global object.'); | 
 |  54   assert_equals(pd.set.call(undefined, null), undefined, '[window] set: returns 
    undefined.'); | 
 |  55   assert_equals(pd.get.call(undefined), null, '[window] set: should be updated.'
    ); | 
 |  56 }, "Test with extracted accessors."); | 
|  22 </script> |  57 </script> | 
| OLD | NEW |