Skip to content

Commit

Permalink
add test of plugins/legend.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Akiyah committed Feb 17, 2014
1 parent 4d28164 commit 8b38c21
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions auto_tests/misc/local.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
-->
<script type="text/javascript" src="../tests/to_dom_coords.js"></script>
<script type="text/javascript" src="../tests/resize.js"></script>
<script type="text/javascript" src="../tests/plugins_legend.js"></script>
<script type="text/javascript" src="../tests/update_options.js"></script>
<script type="text/javascript" src="../tests/update_while_panning.js"></script>
<script type="text/javascript" src="../tests/utils_test.js"></script>
Expand Down
46 changes: 46 additions & 0 deletions auto_tests/tests/plugins_legend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* @fileoverview FILL THIS IN
*
* @author [email protected] (Akiyah)
*/
var pluginsLegendTestCase = TestCase("plugins-legend");

pluginsLegendTestCase.prototype.setUp = function() {
document.body.innerHTML = "<div id='graph'></div>";
};

pluginsLegendTestCase.prototype.tearDown = function() {
};

pluginsLegendTestCase.prototype.testLegendEscape = function() {
var opts = {
width: 480,
height: 320
};
var data = "X,<script>alert('XSS')</script>\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: "<script>alert('XSS')</script>",
yval: 10,
}],
dygraph: g
}
legendPlugin.select(e);

var legendSpan = $(legendPlugin.legend_div_).find("span b span");
assertEquals("&lt;script&gt;alert('XSS')&lt;/script&gt;", legendSpan.html());
};

0 comments on commit 8b38c21

Please sign in to comment.