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

Unified 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, 3 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/css/variables/cssom-foreach.html
diff --git a/LayoutTests/fast/css/variables/cssom-foreach.html b/LayoutTests/fast/css/variables/cssom-foreach.html
new file mode 100644
index 0000000000000000000000000000000000000000..8fd8dc9bdb58cd6c53e53ca5e3254f1ca82b54b6
--- /dev/null
+++ b/LayoutTests/fast/css/variables/cssom-foreach.html
@@ -0,0 +1,37 @@
+<!doctype html>
+<head><script src="../../js/resources/js-test-pre.js"></script></head>
+
+<div id="test" style="var-a: apple; var-b: banana; var-c: carrot"></div>
+
+<script>
+description('This tests basic calling of forEach on a CSSVariablesMap object.');
+
+var div = document.querySelector('#test');
+var log;
+
+shouldThrow('div.style.var.forEach()', '"TypeError: Failed to execute \'forEach\' on \'CSSVariablesMap\': 1 argument required, but only 0 present."');
+shouldThrow('div.style.var.forEach("Not a function.")', '"TypeError: Type error"');
+
+debug('\nTest calling forEach without thisArg specified:');
+log = [];
+div.style.var.forEach(function(value, name, map) {
+ log.push(map + ', ' + name + ': ' + value + ', this == ' + this);
+});
+shouldBeEqualToString('log[0]', '[object CSSVariablesMap], a: apple, this == [object Window]');
+shouldBeEqualToString('log[1]', '[object CSSVariablesMap], b: banana, this == [object Window]');
+shouldBeEqualToString('log[2]', '[object CSSVariablesMap], c: carrot, this == [object Window]');
+shouldBe('log.length', '3');
+
+debug('\nTest calling forEach with thisArg specified:');
+log = [];
+div.style.var.forEach(function(value, name, map) {
+ log.push(map + ', ' + name + ': ' + value + ', this == ' + JSON.stringify(this));
+}, {test: 'pass'});
+shouldBeEqualToString('log[0]', '[object CSSVariablesMap], a: apple, this == {"test":"pass"}');
+shouldBeEqualToString('log[1]', '[object CSSVariablesMap], b: banana, this == {"test":"pass"}');
+shouldBeEqualToString('log[2]', '[object CSSVariablesMap], c: carrot, this == {"test":"pass"}');
+shouldBe('log.length', '3');
+
+debug('');
+</script>
+<script src="../../js/resources/js-test-post.js"></script>

Powered by Google App Engine
This is Rietveld 408576698