2 <head><script src="../../../resources/js-test.js"></script></head>
4 <div id="test" style="var-a: apple; var-b: banana; var-c: carrot"></div>
7 description('This tests basic calling of forEach on a CSSVariablesMap object.');
9 var div = document.querySelector('#test');
12 shouldThrow('div.style.var.forEach()', '"TypeError: Failed to execute \'forEach\' on \'CSSVariablesMap\': 1 argument required, but only 0 present."');
13 shouldThrow('div.style.var.forEach("Not a function.")', '"TypeError: Failed to execute \'forEach\' on \'CSSVariablesMap\': The callback provided as parameter 1 is not a function."');
15 debug('\nTest calling forEach without thisArg specified:');
17 div.style.var.forEach(function(value, name, map) {
18 log.push(map + ', ' + name + ': ' + value + ', this == ' + this);
20 shouldBeEqualToString('log[0]', '[object CSSVariablesMap], a: apple, this == [object Window]');
21 shouldBeEqualToString('log[1]', '[object CSSVariablesMap], b: banana, this == [object Window]');
22 shouldBeEqualToString('log[2]', '[object CSSVariablesMap], c: carrot, this == [object Window]');
23 shouldBe('log.length', '3');
25 debug('\nTest calling forEach with thisArg specified:');
27 div.style.var.forEach(function(value, name, map) {
28 log.push(map + ', ' + name + ': ' + value + ', this == ' + JSON.stringify(this));
30 shouldBeEqualToString('log[0]', '[object CSSVariablesMap], a: apple, this == {"test":"pass"}');
31 shouldBeEqualToString('log[1]', '[object CSSVariablesMap], b: banana, this == {"test":"pass"}');
32 shouldBeEqualToString('log[2]', '[object CSSVariablesMap], c: carrot, this == {"test":"pass"}');
33 shouldBe('log.length', '3');