Page 1 of 2

"Waiting for page to load" since Chrome 72

Posted: Thu Apr 11, 2019 11:09 am
by paulb
Hi,
our integration tests are failing with being stuck on the "Waiting for page to load" message.
When we launch the test, we start on a blank page and use setUrl to navigate to our page. Up until Chrome 71 this has been working like a charm. Unfortunately since Chrome 72 this is broken (using a portable version of Chrome 71 still works).
The page loads fine and all tests prior to loading the page are run but as soon as the page has been loaded the test just shuts down. No error message is shown and no timeout is met. It looks like the javascript containing the testcase is lost after the reload therefore no further update of the test is done.
Is there any information about this behaviour?

Re: "Waiting for page to load" on since Chrome 72

Posted: Thu Apr 11, 2019 11:11 am
by nickolay
Hi,

No, this is something new. I'll investigate soon, stay tuned.

Re: "Waiting for page to load" on since Chrome 72

Posted: Mon Apr 15, 2019 5:49 pm
by nickolay
Sorry for the delay. I made a brief investigation, the Siesta's own tests related to the `setUrl` passes, using Chrome 73. Can try with that version? If the problem still persist, can you provide a reduced test case, reproducing the problem?

Re: "Waiting for page to load" on since Chrome 72

Posted: Wed Apr 17, 2019 1:28 pm
by paulb
Ok looks like my test setup is not correct. We use setUrl without enablePageRedirect. Any idea how this could have worked with Chrome 71? And why it crashes since Chrome 72?
Anyhow, we updated our tests to use enablePageRedirect but now new problems occur. In our tests we rely on the existence of the ExtJS framework but it is not available now. If I understand Siesta correctly, using enablePageRedirect is creating two iframes, one for the test-case and another one for the site to test. The solution for my problem would be to load additional scripts (i.e. ext-all.js) before the test-case is executed. Is there an easy way to do this that I missed?

Re: "Waiting for page to load" on since Chrome 72

Posted: Wed Apr 17, 2019 1:37 pm
by nickolay
Weird, it should not work w/o `enablePageRedirect` of course.

Yes, `enablePageRedirect` creates 2 iframes. You can access the iframe with the website using `t.global` perhaps that will be enough? (the website will have ExtJS loaded I assume) If that is not enough, you can load any code for the test script manually (like using <script> tag), unfortunately there's no helper method for that in Siesta). Some inspiration code:
            var node = document.createElement("script")

            node.setAttribute("type", 'text/javascript')
            node.setAttribute("src", URL)
            
            node.onload = node.onreadystatechange = function () {
                if (!node.readyState || node.readyState == "loaded" || node.readyState == "complete" || node.readyState == 4 && node.status == 200) {
                    node.onload = node.onreadystatechange = null
                    
                    CALLBACK()
                }
            }
            
            document.getElementsByTagName('head')[ 0 ].appendChild(node)

            return node

Re: "Waiting for page to load" on since Chrome 72

Posted: Thu Apr 18, 2019 8:46 am
by paulb
Using t.global unfortunately is not enough.
Is there a way to override the setup method of Scope.Provider.Role.WithDOM, or better yet override the launchTest method of Siesta.Project.Browser.meta.extend so that my additional files are added to the testScriptScopeProvider before the test-case?

edit: Basically I want all of my preloads to be loaded before the test-case in the iframe that holds the test-case.

Re: "Waiting for page to load" since Chrome 72

Posted: Wed May 08, 2019 10:15 am
by paulb
Ok I managed to make our tests run again by usind this override:
Siesta.Project.Browser.meta.extend({
    override: {
        launchTest: function() {
            var me = this,
                setupFn = Scope.Provider.IFrame.prototype.setup;
            
            Scope.Provider.IFrame.prototype.setup = function(callback) {
                var iframeProvider = this;
                
                for (var i = 0; i < me.preload.length; i++) {
                    iframeProvider.addPreload(me.preload[i]);
                }
                
                setupFn.call(iframeProvider, callback);
            };
            
            me.SUPERARG(arguments);
            
            Scope.Provider.IFrame.prototype.setup = setupFn;
        }
    }
});
Does this look stable to you? Any recommendations for a better implementation?

Furthermore, isn't this a feature that should not require this override? A test script that requires some other scripts does not sound like an uncommon thing to do and using enablePageRedirect I see no option to do this. Or am I missing some other point of view here?

Re: "Waiting for page to load" since Chrome 72

Posted: Wed May 08, 2019 1:09 pm
by nickolay
Sorry, somehow missed your previous post.
A test script that requires some other scripts does not sound like an uncommon thing to do and using enablePageRedirect I see no option to do this.
Yes, this feature makes sense. I went ahead and added it to the core, as the new config option `testPreload`, which is the same as "preload" (supports `{ text : "code" }`, etc) but for the context of the test script. It will be available in the tomorrow nightly, please verify it works for you.

Re: "Waiting for page to load" since Chrome 72

Posted: Wed May 08, 2019 1:30 pm
by paulb
Will do and get back to you tomorrow.

Thanks a lot, for your quick responses and help!

Re: "Waiting for page to load" since Chrome 72

Posted: Thu May 09, 2019 9:05 am
by paulb
Just checked the nightly and testPreload works like a charm!
Great work!