Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / css / variables / cssom-foreach.html
1 <!doctype html>
2 <head><script src="../../../resources/js-test.js"></script></head>
3
4 <div id="test" style="var-a: apple; var-b: banana; var-c: carrot"></div>
5
6 <script>
7 description('This tests basic calling of forEach on a CSSVariablesMap object.');
8
9 var div = document.querySelector('#test');
10 var log;
11
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."');
14
15 debug('\nTest calling forEach without thisArg specified:');
16 log = [];
17 div.style.var.forEach(function(value, name, map) {
18     log.push(map + ', ' + name + ': ' + value + ', this == ' + this);
19 });
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');
24
25 debug('\nTest calling forEach with thisArg specified:');
26 log = [];
27 div.style.var.forEach(function(value, name, map) {
28     log.push(map + ', ' + name + ': ' + value + ', this == ' + JSON.stringify(this));
29 }, {test: 'pass'});
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');
34
35 debug('');
36 </script>