test-page-worker.js 1.1 KB

1234567891011121314151617181920212223242526272829
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. // get title directly
  5. self.postMessage(["equal", document.title, "Page Worker test",
  6. "Correct page title accessed directly"]);
  7. // get <p> directly
  8. let p = document.getElementById("paragraph");
  9. self.postMessage(["ok", !!p, "<p> can be accessed directly"]);
  10. self.postMessage(["equal", p.firstChild.nodeValue,
  11. "Lorem ipsum dolor sit amet.",
  12. "Correct text node expected"]);
  13. // Modify page
  14. let div = document.createElement("div");
  15. div.setAttribute("id", "block");
  16. div.appendChild(document.createTextNode("Test text created"));
  17. document.body.appendChild(div);
  18. // Check back the modification
  19. div = document.getElementById("block");
  20. self.postMessage(["ok", !!div, "<div> can be accessed directly"]);
  21. self.postMessage(["equal", div.firstChild.nodeValue,
  22. "Test text created", "Correct text node expected"]);
  23. self.postMessage(["done"]);