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

Side by Side Diff: LayoutTests/fast/css/variables/cssom-foreach.html

Issue 21006006: Add forEach() to CSSVariablesMap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase and review changes Created 7 years, 2 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!doctype html>
2 <head><script src="../../js/resources/js-test-pre.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: Type error" ');
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 == [ob ject Window]');
21 shouldBeEqualToString('log[1]', '[object CSSVariablesMap], b: banana, this == [o bject Window]');
22 shouldBeEqualToString('log[2]', '[object CSSVariablesMap], c: carrot, this == [o bject 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(th is));
29 }, {test: 'pass'});
30 shouldBeEqualToString('log[0]', '[object CSSVariablesMap], a: apple, this == {"t est":"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>
37 <script src="../../js/resources/js-test-post.js"></script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698