@@ -33,21 +33,23 @@ describe( 'DomConverter', () => {
3333 } ) ;
3434
3535 describe ( 'focus()' , ( ) => {
36- let viewEditable , domEditable , viewDocument ;
36+ let viewEditable , domEditable , domEditableParent , viewDocument ;
3737
3838 beforeEach ( ( ) => {
3939 viewDocument = new ViewDocument ( ) ;
4040 viewEditable = new ViewEditable ( 'div' ) ;
4141 viewEditable . document = viewDocument ;
4242
4343 domEditable = document . createElement ( 'div' ) ;
44+ domEditableParent = document . createElement ( 'div' ) ;
4445 converter . bindElements ( domEditable , viewEditable ) ;
4546 domEditable . setAttribute ( 'contenteditable' , 'true' ) ;
46- document . body . appendChild ( domEditable ) ;
47+ domEditableParent . appendChild ( domEditable ) ;
48+ document . body . appendChild ( domEditableParent ) ;
4749 } ) ;
4850
4951 afterEach ( ( ) => {
50- document . body . removeChild ( domEditable ) ;
52+ document . body . removeChild ( domEditableParent ) ;
5153 viewDocument . destroy ( ) ;
5254 } ) ;
5355
@@ -69,19 +71,46 @@ describe( 'DomConverter', () => {
6971 } ) ;
7072
7173 // https://github.com/ckeditor/ckeditor5-engine/issues/951
72- it ( 'should actively prevent window scroll in WebKit' , ( ) => {
74+ // https://github.com/ckeditor/ckeditor5-engine/issues/957
75+ it ( 'should actively prevent scrolling' , ( ) => {
7376 const scrollToSpy = testUtils . sinon . stub ( global . window , 'scrollTo' ) ;
74- const scrollLeftSpy = sinon . spy ( ) ;
75- const scrollTopSpy = sinon . spy ( ) ;
77+ const editableScrollLeftSpy = sinon . spy ( ) ;
78+ const editableScrollTopSpy = sinon . spy ( ) ;
79+ const parentScrollLeftSpy = sinon . spy ( ) ;
80+ const parentScrollTopSpy = sinon . spy ( ) ;
81+ const documentElementScrollLeftSpy = sinon . spy ( ) ;
82+ const documentElementScrollTopSpy = sinon . spy ( ) ;
7683
7784 Object . defineProperties ( domEditable , {
7885 scrollLeft : {
7986 get : ( ) => 20 ,
80- set : scrollLeftSpy
87+ set : editableScrollLeftSpy
8188 } ,
8289 scrollTop : {
8390 get : ( ) => 200 ,
84- set : scrollTopSpy
91+ set : editableScrollTopSpy
92+ }
93+ } ) ;
94+
95+ Object . defineProperties ( domEditableParent , {
96+ scrollLeft : {
97+ get : ( ) => 40 ,
98+ set : parentScrollLeftSpy
99+ } ,
100+ scrollTop : {
101+ get : ( ) => 400 ,
102+ set : parentScrollTopSpy
103+ }
104+ } ) ;
105+
106+ Object . defineProperties ( global . document . documentElement , {
107+ scrollLeft : {
108+ get : ( ) => 60 ,
109+ set : documentElementScrollLeftSpy
110+ } ,
111+ scrollTop : {
112+ get : ( ) => 600 ,
113+ set : documentElementScrollTopSpy
85114 }
86115 } ) ;
87116
@@ -90,8 +119,12 @@ describe( 'DomConverter', () => {
90119
91120 converter . focus ( viewEditable ) ;
92121 sinon . assert . calledWithExactly ( scrollToSpy , 10 , 100 ) ;
93- sinon . assert . calledWithExactly ( scrollLeftSpy , 20 ) ;
94- sinon . assert . calledWithExactly ( scrollTopSpy , 200 ) ;
122+ sinon . assert . calledWithExactly ( editableScrollLeftSpy , 20 ) ;
123+ sinon . assert . calledWithExactly ( editableScrollTopSpy , 200 ) ;
124+ sinon . assert . calledWithExactly ( parentScrollLeftSpy , 40 ) ;
125+ sinon . assert . calledWithExactly ( parentScrollTopSpy , 400 ) ;
126+ sinon . assert . calledWithExactly ( documentElementScrollLeftSpy , 60 ) ;
127+ sinon . assert . calledWithExactly ( documentElementScrollTopSpy , 600 ) ;
95128 } ) ;
96129 } ) ;
97130
0 commit comments