From 7954a2dea5acd9f1a3b1677aaa3a748c66ca705c Mon Sep 17 00:00:00 2001 From: Akiyah Date: Tue, 18 Feb 2014 01:58:00 +0900 Subject: [PATCH] add test of plugins/legend.js --- auto_tests/misc/local.html | 1 + auto_tests/tests/plugins_legend.js | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 auto_tests/tests/plugins_legend.js diff --git a/auto_tests/misc/local.html b/auto_tests/misc/local.html index 3590fa5..74871e8 100644 --- a/auto_tests/misc/local.html +++ b/auto_tests/misc/local.html @@ -58,6 +58,7 @@ + diff --git a/auto_tests/tests/plugins_legend.js b/auto_tests/tests/plugins_legend.js new file mode 100644 index 0000000..3288329 --- /dev/null +++ b/auto_tests/tests/plugins_legend.js @@ -0,0 +1,46 @@ +/** + * @fileoverview FILL THIS IN + * + * @author akiya.mizukoshi@gmail.com (Akiyah) + */ +var pluginsLegendTestCase = TestCase("plugins-legend"); + +pluginsLegendTestCase.prototype.setUp = function() { + document.body.innerHTML = "
"; +}; + +pluginsLegendTestCase.prototype.tearDown = function() { +}; + +pluginsLegendTestCase.prototype.testLegendEscape = function() { + var opts = { + width: 480, + height: 320 + }; + var data = "X,\n" + + "0,-1\n" + + "1,0\n" + + "2,1\n" + + "3,0\n" + ; + + var graph = document.getElementById("graph"); + var g = new Dygraph(graph, data, opts); + + var legendPlugin = new Dygraph.Plugins.Legend(); + legendPlugin.activate(g); + var e = { + selectedX: 'selectedX', + selectedPoints: [{ + canvasy: 100, + name: "", + yval: 10, + }], + dygraph: g + } + legendPlugin.select(e); + + var legendSpan = $(legendPlugin.legend_div_).find("span b span"); + assertEquals("<script>alert('XSS')</script>", legendSpan.html()); +}; + -- 2.7.4