tor-browser

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

browser_webconsole_deprecation_warning.js (1953B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Check that calling deprecated getter displays a deprecation warning.
      7 const TEST_URI =
      8  "data:text/html;charset=utf8,<!DOCTYPE html><h1>Deprecation warning";
      9 
     10 add_task(async function () {
     11  const hud = await openNewTabAndConsole(TEST_URI);
     12 
     13  const deprecatedWarningMessageText = "mozPressure is deprecated";
     14 
     15  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () {
     16    content.testMouseEvent = new content.MouseEvent("click");
     17    content.wrappedJSObject.console.log("oi-test", content.testMouseEvent);
     18  });
     19  const node = await waitFor(() => findConsoleAPIMessage(hud, "oi-test"));
     20 
     21  info("Expand the MouseEvent object");
     22  await expandObjectInspectorNode(node.querySelector(".tree .tree-node"));
     23 
     24  info("Wait for a bit so any warning message could be displayed");
     25  await wait(1000);
     26  ok(
     27    !findWarningMessage(hud, deprecatedWarningMessageText, ".warn"),
     28    "Expanding the MouseEvent object didn't triggered the deprecation warning"
     29  );
     30 
     31  info("Access the deprecated getter to trigger a warning message");
     32  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () {
     33    content.testMouseEvent.mozPressure;
     34  });
     35 
     36  await waitFor(() =>
     37    findWarningMessage(hud, deprecatedWarningMessageText, ".warn")
     38  );
     39  ok(
     40    true,
     41    "Calling the mozPressure getter did triggered the deprecation warning"
     42  );
     43 
     44  info("Clear the console and access the deprecated getter again");
     45  await clearOutput(hud);
     46  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () {
     47    content.testMouseEvent.mozPressure;
     48  });
     49  info("Wait for a bit so any warning message could be displayed");
     50  await wait(1000);
     51  ok(
     52    !findWarningMessage(hud, deprecatedWarningMessageText, ".warn"),
     53    "Calling the mozPressure getter a second time did not trigger the deprecation warning again"
     54  );
     55 });