diff options
author | Luke <luke.wilde@live.co.uk> | 2020-07-24 21:24:11 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-25 12:35:15 +0200 |
commit | 08221139a57ddf941d9ba44f9a700d22e33d6665 (patch) | |
tree | 7708ece0e2c0f4b498c5bb3aa6a7aa70a77b57c2 /Libraries/LibWeb/Tests/test-common.js | |
parent | 1d6a3a5e8fd418c2f36bb002282a2c6192b75f79 (diff) | |
download | serenity-08221139a57ddf941d9ba44f9a700d22e33d6665.zip |
test-web: Add ability to change page mid-test
This allows you to not have to write a separate test file
for the same thing but in a different situation.
This doesn't handle when you change the page with location.href
however.
Changes the name of the page load handlers to prevent confusion
with this.
Diffstat (limited to 'Libraries/LibWeb/Tests/test-common.js')
-rw-r--r-- | Libraries/LibWeb/Tests/test-common.js | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/Libraries/LibWeb/Tests/test-common.js b/Libraries/LibWeb/Tests/test-common.js index 7add466d52..54d0b830c6 100644 --- a/Libraries/LibWeb/Tests/test-common.js +++ b/Libraries/LibWeb/Tests/test-common.js @@ -1,28 +1,32 @@ // NOTE: The tester loads in LibJS's test-common to prevent duplication. +// NOTE: "window.libweb_tester" is set to a special tester object. +// The object currently provides the following functions: +// - changePage(url) - change page to given URL. Everything afterwards will refer to the new page. + let __PageToLoad__; // This tells the tester which page to load. // This will only be checked when we look at which page the test wants to use. -// Subsequent calls to loadPage in before/after load will be ignored. +// Subsequent calls to loadPage in before/after initial load will be ignored. let loadPage; -let __BeforePageLoad__ = () => {}; +let __BeforeInitialPageLoad__ = () => {}; -// This function will be run just before loading the page. +// This function will be called just before loading the initial page. // This is useful for injecting event listeners. // Defaults to an empty function. -let beforePageLoad; +let beforeInitialPageLoad; -let __AfterPageLoad__ = () => {}; +let __AfterInitialPageLoad__ = () => {}; -// This function will be run just after loading the page. +// This function will be called just after loading the initial page. // This is where the main bulk of the tests should be. // Defaults to an empty function. -let afterPageLoad; +let afterInitialPageLoad; (() => { loadPage = (page) => __PageToLoad__ = page; - beforePageLoad = (callback) => __BeforePageLoad__ = callback; - afterPageLoad = (callback) => __AfterPageLoad__ = callback; + beforeInitialPageLoad = (callback) => __BeforeInitialPageLoad__ = callback; + afterInitialPageLoad = (callback) => __AfterInitialPageLoad__ = callback; })(); |