| Index: third_party/WebKit/LayoutTests/fast/dom/lenient-this.html
|
| diff --git a/third_party/WebKit/LayoutTests/fast/dom/lenient-this.html b/third_party/WebKit/LayoutTests/fast/dom/lenient-this.html
|
| index 6931f9b0df8e7773bb6b224ffd1ef218c4bc0063..9d73bb525f588d087f63e02c3260ab1100eacf63 100644
|
| --- a/third_party/WebKit/LayoutTests/fast/dom/lenient-this.html
|
| +++ b/third_party/WebKit/LayoutTests/fast/dom/lenient-this.html
|
| @@ -18,5 +18,41 @@ test(function() {
|
| assert_throws(null, function() {
|
| Document.prototype.onmousedown = 'foo';
|
| }, "Document.prototype is invalid as |this|.");
|
| -});
|
| +}, "Test [LenientThis] and non-[LenientThis].");
|
| +
|
| +test(function() {
|
| + var noop = function() {};
|
| + var testPatterns = [
|
| + {name: 'document', instance: document, holder: Document.prototype, noninstance: window},
|
| + {name: 'window', instance: window, holder: window, noninstance: document}
|
| + ];
|
| + function msg(pattern, text) {
|
| + return '[' + pattern.name + '] ' + text;
|
| + }
|
| + for (var p, i = 0; p = testPatterns[i]; ++i) {
|
| + var pd = Object.getOwnPropertyDescriptor(p.holder, 'onmouseleave');
|
| + // get
|
| + assert_equals(pd.get.call(p.noninstance), undefined, msg(p, 'get: non-instance should return undefined.'));
|
| + assert_equals(pd.get.call(p.instance), null, msg(p, 'get: instance should return null by default.'));
|
| +
|
| + // set
|
| + assert_equals(pd.set.call(p.noninstance, noop), undefined, msg(p, 'set: setter always returns undefined.'));
|
| + assert_equals(pd.get.call(p.noninstance), undefined, msg(p, 'set: non-instance should returns undefined.'));
|
| + assert_equals(pd.set.call(p.instance, noop), undefined, msg(p, 'set: even instance should return undefined.'));
|
| + assert_equals(pd.get.call(p.instance), noop, msg(p, 'set: instance should return the assigned function.'));
|
| + }
|
| +
|
| + // document specific tests.
|
| + pd = Object.getOwnPropertyDescriptor(Document.prototype, 'onmouseleave');
|
| + assert_equals(pd.get.call(null), undefined, '[document] get: null is not a valid instance.');
|
| + assert_equals(pd.get.call(undefined), undefined, '[document] get: undefined is not a valid instance.');
|
| +
|
| + // window specific tests.
|
| + pd = Object.getOwnPropertyDescriptor(window, 'onmouseleave');
|
| + assert_equals(pd.get.call(null), noop, '[window] get: null should be interpreted as the global object.');
|
| + assert_equals(pd.get.call(undefined), noop, '[window] get: undefined should be interpreted as the global object.');
|
| + assert_equals(pd.set.call(undefined, null), undefined, '[window] set: returns undefined.');
|
| + assert_equals(pd.get.call(undefined), null, '[window] set: should be updated.');
|
| +
|
| +}, "Test with extracted accessors.");
|
| </script>
|
|
|