test-common.js 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. // NOTE: The tester loads in LibJS's test-common to prevent duplication.
  2. // NOTE: "window.libweb_tester" is set to a special tester object.
  3. // See libweb_tester.d.ts for definitions.
  4. let __PageToLoad__;
  5. // This tells the tester which page to load.
  6. // This will only be checked when we look at which page the test wants to use.
  7. // Subsequent calls to loadPage in before/after initial load will be ignored.
  8. let loadPage;
  9. let __BeforeInitialPageLoad__ = () => {};
  10. // This function will be called just before loading the initial page.
  11. // This is useful for injecting event listeners.
  12. // Defaults to an empty function.
  13. let beforeInitialPageLoad;
  14. let __AfterInitialPageLoad__ = () => {};
  15. // This function will be called just after loading the initial page.
  16. // This is where the main bulk of the tests should be.
  17. // Defaults to an empty function.
  18. let afterInitialPageLoad;
  19. (() => {
  20. loadPage = page => (__PageToLoad__ = page);
  21. beforeInitialPageLoad = callback => (__BeforeInitialPageLoad__ = callback);
  22. afterInitialPageLoad = callback => (__AfterInitialPageLoad__ = callback);
  23. })();