browser_asrouter_snippets.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. "use strict";
  2. const {ASRouter} = ChromeUtils.import("resource://activity-stream/lib/ASRouter.jsm");
  3. const {SnippetsTestMessageProvider} = ChromeUtils.import("resource://activity-stream/lib/SnippetsTestMessageProvider.jsm");
  4. test_newtab({
  5. async before() {
  6. let data = SnippetsTestMessageProvider.getMessages().find(m => m.id === "SIMPLE_BELOW_SEARCH_TEST_1");
  7. ASRouter.messageChannel.sendAsyncMessage("ASRouter:parent-to-child", {type: "SET_MESSAGE", data});
  8. },
  9. test: async function test_simple_below_search_snippet() {
  10. // Verify the simple_below_search_snippet renders in container below searchbox
  11. // and nothing is rendered in the footer.
  12. await ContentTaskUtils.waitForCondition(
  13. () => content.document.querySelector(".below-search-snippet .SimpleBelowSearchSnippet"),
  14. "Should find the snippet inside the below search container");
  15. is(0, content.document.querySelector("#footer-asrouter-container").childNodes.length,
  16. "Should not find any snippets in the footer container");
  17. },
  18. });
  19. test_newtab({
  20. async before() {
  21. let data = SnippetsTestMessageProvider.getMessages().find(m => m.id === "SIMPLE_TEST_1");
  22. ASRouter.messageChannel.sendAsyncMessage("ASRouter:parent-to-child", {type: "SET_MESSAGE", data});
  23. },
  24. test: async function test_simple_snippet() {
  25. // Verify the simple_snippet renders in the footer and the container below
  26. // searchbox is not rendered.
  27. await ContentTaskUtils.waitForCondition(
  28. () => content.document.querySelector("#footer-asrouter-container .SimpleSnippet"),
  29. "Should find the snippet inside the footer container");
  30. ok(!content.document.querySelector(".below-search-snippet"),
  31. "Should not find any snippets below search");
  32. },
  33. });