@@ -71,26 +71,28 @@ public function testResizeWindow(): void
7171 {
7272 $ this ->getSession ()->visit ($ this ->pathTo ('/index.html ' ));
7373 $ session = $ this ->getSession ();
74+ $ expectedWidth = 640 ;
75+ $ expectedHeight = 480 ;
7476
75- $ session ->resizeWindow (400 , 300 );
77+ $ session ->resizeWindow ($ expectedWidth , $ expectedHeight );
7678 $ session ->wait (1000 , 'false ' );
77- $ jsWindowSizeScript = <<<'JS'
78- (function(){
79- var boolSizeCheck = Math.abs(window.outerHeight - 300) <= 100 && Math.abs(window.outerWidth - 400) <= 100;
80- if (boolSizeCheck){
81- return true;
82- }
83- var w = window,
84- d = document,
85- e = d.documentElement,
86- g = d.getElementsByTagName('body')[0],
87- x = w.innerWidth || e.clientWidth || g.clientWidth,
88- y = w.innerHeight|| e.clientHeight|| g.clientHeight;
89- boolSizeCheck = Math.abs(y - 300) <= 100 && Math.abs(x - 400) <= 100;
90- return boolSizeCheck;
79+
80+ $ jsWindowSizeScript = <<<"JS"
81+ (function () {
82+ var check = function (actualWidth, actualHeight) {
83+ return Math.abs(actualWidth - $ expectedWidth) <= 100
84+ && Math.abs(actualHeight - $ expectedHeight) <= 100;
85+ },
86+ htmlElem = document.documentElement,
87+ bodyElem = document.getElementsByTagName('body')[0];
88+
89+ return check(window.outerWidth, window.outerHeight)
90+ || check(
91+ window.innerWidth || htmlElem.clientWidth || bodyElem.clientWidth,
92+ window.innerHeight || htmlElem.clientHeight || bodyElem.clientHeight
93+ );
9194 })();
9295JS ;
93-
9496 $ this ->assertTrue ($ session ->evaluateScript ($ jsWindowSizeScript ));
9597 }
9698
0 commit comments