Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/lenient-this.html

Issue 2506393004: binding: Makes non-cross-origin-accessible attrs be accessor props. (Closed)
Patch Set: Synced. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..39a6c864cc50fae61abf1b9af2123b2f77c95fdd 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/lenient-this.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/lenient-this.html
@@ -4,19 +4,54 @@
<script src="../../resources/testharnessreport.js"></script>
<script>
test(function() {
- // GlobalEventHandlers.onmouseenter is [LenientThis].
- assert_equals(document.onmouseenter, null, "|this| is an appropriate object.");
- assert_equals(Document.prototype.onmouseenter, undefined, "|this| is not an appropriate object.");
- Document.prototype.onmouseenter = 'foo'; // must not throw.
- assert_equals(Document.prototype.onmouseenter, undefined, "the value must not change.");
+ // GlobalEventHandlers.onmouseenter is [LenientThis].
+ assert_equals(document.onmouseenter, null, "|this| is an appropriate object.");
+ assert_equals(Document.prototype.onmouseenter, undefined, "|this| is not an appropriate object.");
+ Document.prototype.onmouseenter = 'foo'; // must not throw.
+ assert_equals(Document.prototype.onmouseenter, undefined, "the value must not change.");
- // GlobalEventHandlers.onmousedown is NOT [LenientThis].
- assert_equals(document.onmousedown, null, "|this| is an appropriate object.");
- assert_throws(null, function() {
- Document.prototype.onmousedown;
- }, "Document.prototype is invalid as |this|.");
- assert_throws(null, function() {
- Document.prototype.onmousedown = 'foo';
- }, "Document.prototype is invalid as |this|.");
-});
+ // GlobalEventHandlers.onmousedown is NOT [LenientThis].
+ assert_equals(document.onmousedown, null, "|this| is an appropriate object.");
+ assert_throws(null, function() {
+ Document.prototype.onmousedown;
+ }, "Document.prototype is invalid as |this|.");
+ 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>

Powered by Google App Engine
This is Rietveld 408576698