@@ -682,6 +682,59 @@ describe('Test splom interactions:', function() {
682
682
. catch ( failTest )
683
683
. then ( done ) ;
684
684
} ) ;
685
+
686
+ it ( '@gl should clear graph and replot when canvas and WebGL context dimensions do not match' , function ( done ) {
687
+ var fig = Lib . extendDeep ( { } , require ( '@mocks/splom_iris.json' ) ) ;
688
+
689
+ function assertDims ( msg , w , h ) {
690
+ var canvas = gd . _fullLayout . _glcanvas ;
691
+ expect ( canvas . node ( ) . width ) . toBe ( w , msg ) ;
692
+ expect ( canvas . node ( ) . height ) . toBe ( h , msg ) ;
693
+
694
+ var gl = canvas . data ( ) [ 0 ] . regl . _gl ;
695
+ expect ( gl . drawingBufferWidth ) . toBe ( w , msg ) ;
696
+ expect ( gl . drawingBufferHeight ) . toBe ( h , msg ) ;
697
+ }
698
+
699
+ var methods = [ 'cleanPlot' , 'supplyDefaults' , 'doCalcdata' ] ;
700
+
701
+ methods . forEach ( function ( m ) { spyOn ( Plots , m ) . and . callThrough ( ) ; } ) ;
702
+
703
+ function assetsFnCall ( msg , exp ) {
704
+ methods . forEach ( function ( m ) {
705
+ expect ( Plots [ m ] ) . toHaveBeenCalledTimes ( exp [ m ] , msg ) ;
706
+ Plots [ m ] . calls . reset ( ) ;
707
+ } ) ;
708
+ }
709
+
710
+ spyOn ( Lib , 'log' ) ;
711
+
712
+ Plotly . plot ( gd , fig ) . then ( function ( ) {
713
+ assetsFnCall ( 'base' , {
714
+ cleanPlot : 1 , // called once from inside Plots.supplyDefaults
715
+ supplyDefaults : 1 ,
716
+ doCalcdata : 1
717
+ } ) ;
718
+ assertDims ( 'base' , 600 , 500 ) ;
719
+ expect ( Lib . log ) . toHaveBeenCalledTimes ( 0 ) ;
720
+
721
+ spyOn ( gd . _fullData [ 0 ] . _module , 'plot' ) . and . callThrough ( ) ;
722
+
723
+ return Plotly . relayout ( gd , { width : 4810 , height : 3656 } ) ;
724
+ } )
725
+ . then ( function ( ) {
726
+ assetsFnCall ( 'after' , {
727
+ cleanPlot : 4 , // 3 three from supplyDefaults, once in drawFramework
728
+ supplyDefaults : 3 , // 1 from relayout, 1 from automargin, 1 in drawFramework
729
+ doCalcdata : 1 // once in drawFramework
730
+ } ) ;
731
+ assertDims ( 'after' , 4810 , 3656 ) ;
732
+ expect ( Lib . log )
733
+ . toHaveBeenCalledWith ( 'WebGL context buffer and canvas dimensions do not match due to browser/WebGL bug. Clearing graph and plotting again.' ) ;
734
+ } )
735
+ . catch ( failTest )
736
+ . then ( done ) ;
737
+ } ) ;
685
738
} ) ;
686
739
687
740
describe ( 'Test splom hover:' , function ( ) {
0 commit comments