Index: chrome/browser/resources/shared/js/cr_test.html |
diff --git a/chrome/browser/resources/shared/js/cr_test.html b/chrome/browser/resources/shared/js/cr_test.html |
index b20281c1f8d1e74a71b76b18bc2f246bdcb0d7ba..27f273ce27ad62c7326eb8650132f9a3c888a908 100644 |
--- a/chrome/browser/resources/shared/js/cr_test.html |
+++ b/chrome/browser/resources/shared/js/cr_test.html |
@@ -57,6 +57,21 @@ function testDefinePropertyWithDefault() { |
assertEquals(2, obj.test_); |
} |
+function testDefinePropertyWithSetter() { |
+ var obj = new EventTarget; |
+ |
+ var hit = false; |
+ function onTestSet(value) { |
+ assertEquals(this, obj); |
+ assertEquals(this.test, 2); |
+ assertEquals(value, 2); |
+ hit = true; |
+ } |
+ cr.defineProperty(obj, 'test', null, 1, onTestSet); |
+ obj.test = 2; |
+ assertTrue(hit); |
+} |
+ |
function testDefinePropertyEvent() { |
var obj = new EventTarget; |
cr.defineProperty(obj, 'test'); |
@@ -136,6 +151,21 @@ function testDefinePropertyAttrWithDefault() { |
assertEquals('b', obj.getAttribute('test')); |
} |
+function testDefinePropertyAttrWithSetter() { |
+ var obj = document.createElement('div'); |
+ |
+ var hit = false; |
+ function onTestSet(value) { |
+ assertEquals(this, obj); |
+ assertEquals(value, 'b'); |
+ assertEquals(this.test, 'b'); |
+ hit = true; |
+ } |
+ cr.defineProperty(obj, 'test', cr.PropertyKind.ATTR, 'a', onTestSet); |
+ obj.test = 'b'; |
+ assertTrue(hit); |
+} |
+ |
function testDefinePropertyAttrEvent() { |
var obj = document.createElement('div'); |
cr.defineProperty(obj, 'test', cr.PropertyKind.ATTR); |
@@ -223,6 +253,27 @@ function testDefinePropertyBoolAttrEvent() { |
assertEquals(1, count); |
} |
+function testDefinePropertyBoolAttrWithTruthyDefaultFails() { |
+ var obj = document.createElement('div'); |
+ assertThrows(function() { |
+ cr.defineProperty(obj, 'test', cr.PropertyKind.BOOL_ATTR, true); |
+ }); |
+} |
+ |
+function testDefinePropertyBoolAttrEvent() { |
+ var obj = document.createElement('div'); |
+ var hit = false; |
+ function onTestSet(value) { |
+ assertEquals(this, obj); |
+ assertTrue(this.test); |
+ assertTrue(value); |
+ hit = true; |
+ } |
+ cr.defineProperty(obj, 'test', cr.PropertyKind.BOOL_ATTR, false, onTestSet); |
+ obj.test = true; |
+ assertTrue(hit); |
+} |
+ |
function testAddSingletonGetter() { |
function Foo() {}; |
cr.addSingletonGetter(Foo); |