##// END OF EJS Templates
Merge pull request #8271 from Carreau/fix-mode-load...
Merge pull request #8271 from Carreau/fix-mode-load Allow to set same mode as existing if load fails.

File last commit:

r17339:592c5060
r21207:de7aa5d0 merge
Show More
isolated_svg.js
90 lines | 3.6 KiB | application/javascript | JavascriptLexer
Pablo de Oliveira
Add casperjs test for isolated SVGs
r13414 //
Paul Ivanov
added test for display() calls with metadata...
r14109 // Test display isolation
Pablo de Oliveira
Fix typo.
r13415 // An object whose metadata contains an "isolated" tag must be isolated
Pablo de Oliveira
Add casperjs test for isolated SVGs
r13414 // from the rest of the document. In the case of inline SVGs, this means
// that multiple SVGs have different scopes. This test checks that there
// are no CSS leaks between two isolated SVGs.
//
casper.notebook_test(function () {
this.evaluate(function () {
var cell = IPython.notebook.get_cell(0);
Jonathan Frederic
Fix isolated svg color tests so 'rgb()' colors are accepted
r16830 cell.set_text( "from IPython.core.display import SVG, display_svg\n" +
"s1 = '''<svg width='1cm' height='1cm' viewBox='0 0 1000 500'>" +
"<defs><style>rect {fill:red;}; </style></defs>" +
"<rect id='r1' x='200' y='100' width='600' height='300' /></svg>" +
"'''\n" +
"s2 = '''<svg width='1cm' height='1cm' viewBox='0 0 1000 500'>" +
"<rect id='r2' x='200' y='100' width='600' height='300' /></svg>" +
"'''\n" +
"display_svg(SVG(s1), metadata=dict(isolated=True))\n" +
"display_svg(SVG(s2), metadata=dict(isolated=True))\n"
Pablo de Oliveira
Add casperjs test for isolated SVGs
r13414 );
cell.execute();
Paul Ivanov
make output code not drop non-mimetype-keyed json
r14112 });
this.then(function() {
var fname=this.test.currentTestFile.split('/').pop().toLowerCase();
Jonathan Frederic
Fix isolated svg color tests so 'rgb()' colors are accepted
r16830 this.echo(fname);
this.echo(this.currentUrl);
Paul Ivanov
make output code not drop non-mimetype-keyed json
r14112 this.evaluate(function (n) {
IPython.notebook.rename(n);
IPython.notebook.save_notebook();
}, {n : fname});
Jonathan Frederic
Fix isolated svg color tests so 'rgb()' colors are accepted
r16830 this.echo(this.currentUrl);
Paul Ivanov
make output code not drop non-mimetype-keyed json
r14112 });
this.then(function() {
url = this.evaluate(function() {
IPython.notebook.rename("foo");
return document.location.href;
Jonathan Frederic
Fix isolated svg color tests so 'rgb()' colors are accepted
r16830 });
Paul Ivanov
make output code not drop non-mimetype-keyed json
r14112 this.echo("renamed" + url);
this.echo(this.currentUrl);
Pablo de Oliveira
Add casperjs test for isolated SVGs
r13414 });
this.wait_for_output(0);
this.then(function () {
var colors = this.evaluate(function () {
var colors = [];
var ifr = __utils__.findAll("iframe");
var svg1 = ifr[0].contentWindow.document.getElementById('r1');
Jonathan Frederic
Fix isolated svg color tests so 'rgb()' colors are accepted
r16830 colors[0] = window.getComputedStyle(svg1).fill;
Pablo de Oliveira
Add casperjs test for isolated SVGs
r13414 var svg2 = ifr[1].contentWindow.document.getElementById('r2');
Jonathan Frederic
Fix isolated svg color tests so 'rgb()' colors are accepted
r16830 colors[1] = window.getComputedStyle(svg2).fill;
Pablo de Oliveira
Add casperjs test for isolated SVGs
r13414 return colors;
});
Jonathan Frederic
Make a nice assert function for properly testing locale specific colors.
r16839 this.assert_colors_equal('#ff0000', colors && colors[0], 'display_svg() First svg should be red');
this.assert_colors_equal('#000000', colors && colors[1], 'display_svg() Second svg should be black');
Pablo de Oliveira
Add casperjs test for isolated SVGs
r13414 });
Paul Ivanov
added test for display() calls with metadata...
r14109
// now ensure that we can pass the same metadata dict to plain old display()
this.thenEvaluate(function () {
var cell = IPython.notebook.get_cell(0);
Paul Ivanov
clear output in-between test runs
r14114 cell.clear_output();
Jonathan Frederic
Fix isolated svg color tests so 'rgb()' colors are accepted
r16830 cell.set_text( "from IPython.display import display\n" +
"display(SVG(s1), metadata=dict(isolated=True))\n" +
"display(SVG(s2), metadata=dict(isolated=True))\n"
Paul Ivanov
added test for display() calls with metadata...
r14109 );
cell.execute();
});
Paul Ivanov
clear output in-between test runs
r14114
this.wait_for_output(0);
Paul Ivanov
added test for display() calls with metadata...
r14109 // same test as original
this.then(function () {
var colors = this.evaluate(function () {
var colors = [];
var ifr = __utils__.findAll("iframe");
var svg1 = ifr[0].contentWindow.document.getElementById('r1');
Jonathan Frederic
Fix isolated svg color tests so 'rgb()' colors are accepted
r16830 colors[0] = window.getComputedStyle(svg1).fill;
Paul Ivanov
added test for display() calls with metadata...
r14109 var svg2 = ifr[1].contentWindow.document.getElementById('r2');
Jonathan Frederic
Fix isolated svg color tests so 'rgb()' colors are accepted
r16830 colors[1] = window.getComputedStyle(svg2).fill;
Paul Ivanov
added test for display() calls with metadata...
r14109 return colors;
});
Jonathan Frederic
Make a nice assert function for properly testing locale specific colors.
r16839 this.assert_colors_equal('#ff0000', colors && colors[0], 'display() First svg should be red');
this.assert_colors_equal('#000000', colors && colors[1], 'display() Second svg should be black');
Paul Ivanov
added test for display() calls with metadata...
r14109 });
Pablo de Oliveira
Add casperjs test for isolated SVGs
r13414 });