tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_aichat_content_actors.js (1207B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Test that AIChatContent actor gets registered when preference is enabled
      8 */
      9 add_task(async function test_aichat_actor_registration() {
     10  await SpecialPowers.pushPrefEnv({
     11    set: [["browser.aiwindow.enabled", true]],
     12  });
     13 
     14  await BrowserTestUtils.withNewTab("about:aichatcontent", async browser => {
     15    const actor =
     16      browser.browsingContext.currentWindowGlobal.getActor("AIChatContent");
     17    Assert.ok(actor, "AIChatContent actor should be registered");
     18  });
     19 
     20  await SpecialPowers.popPrefEnv();
     21 });
     22 
     23 /**
     24 * Test that AIChatContent actor is not available when preference is disabled
     25 */
     26 add_task(async function test_aichat_actor_disabled() {
     27  await SpecialPowers.pushPrefEnv({
     28    set: [["browser.aiwindow.enabled", false]],
     29  });
     30 
     31  await BrowserTestUtils.withNewTab("about:aichatcontent", async browser => {
     32    Assert.throws(
     33      () =>
     34        browser.browsingContext.currentWindowGlobal.getActor("AIChatContent"),
     35      /NotFoundError/,
     36      "AIChatContent actor should not be available when disabled"
     37    );
     38  });
     39 
     40  await SpecialPowers.popPrefEnv();
     41 });