|
1 | 1 | var Plotly = require('@lib');
|
2 | 2 | var Lib = require('@src/lib');
|
3 | 3 | var Plots = require('@src/plots/plots');
|
| 4 | +var plotApi = require('@src/plot_api/plot_api'); |
4 | 5 | var SUBPLOT_PATTERN = require('@src/plots/cartesian/constants').SUBPLOT_PATTERN;
|
5 | 6 |
|
6 | 7 | var d3 = require('d3');
|
@@ -682,6 +683,39 @@ describe('Test splom interactions:', function() {
|
682 | 683 | .catch(failTest)
|
683 | 684 | .then(done);
|
684 | 685 | });
|
| 686 | + |
| 687 | + it('@gl should clear graph and replot when canvas and WebGL context dimensions do not match', function(done) { |
| 688 | + var fig = Lib.extendDeep({}, require('@mocks/splom_iris.json')); |
| 689 | + |
| 690 | + function assertDims(msg, w, h) { |
| 691 | + var canvas = gd._fullLayout._glcanvas; |
| 692 | + expect(canvas.node().width).toBe(w, msg); |
| 693 | + expect(canvas.node().height).toBe(h, msg); |
| 694 | + |
| 695 | + var gl = canvas.data()[0].regl._gl; |
| 696 | + expect(gl.drawingBufferWidth).toBe(w, msg); |
| 697 | + expect(gl.drawingBufferHeight).toBe(h, msg); |
| 698 | + } |
| 699 | + |
| 700 | + spyOn(plotApi, 'newPlot').and.callThrough(); |
| 701 | + spyOn(Lib, 'log'); |
| 702 | + |
| 703 | + Plotly.plot(gd, fig).then(function() { |
| 704 | + expect(plotApi.newPlot).toHaveBeenCalledTimes(0); |
| 705 | + expect(Lib.log).toHaveBeenCalledTimes(0); |
| 706 | + assertDims('base', 600, 500); |
| 707 | + |
| 708 | + return Plotly.relayout(gd, {width: 4810, height: 3656}); |
| 709 | + }) |
| 710 | + .then(function() { |
| 711 | + expect(plotApi.newPlot).toHaveBeenCalledTimes(1); |
| 712 | + expect(Lib.log) |
| 713 | + .toHaveBeenCalledWith('WebGL context buffer and canvas dimensions do not match, due to browser/WebGL bug. Clearing graph and plotting again.'); |
| 714 | + assertDims('base', 4810, 3656); |
| 715 | + }) |
| 716 | + .catch(failTest) |
| 717 | + .then(done); |
| 718 | + }); |
685 | 719 | });
|
686 | 720 |
|
687 | 721 | describe('Test splom hover:', function() {
|
|
0 commit comments