summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/plugins/browser_CTP_zoom.js
blob: eee2ec1837976137fd24d81b8abcb86badcfdc47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"use strict";

var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir.replace(
  "chrome://mochitests/content/",
  "http://127.0.0.1:8888/"
);

var gTestBrowser = null;

add_task(async function() {
  registerCleanupFunction(function() {
    clearAllPluginPermissions();
    Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
    FullZoom.reset(); // must be called before closing the tab we zoomed!
    gBrowser.removeCurrentTab();
    window.focus();
    gTestBrowser = null;
  });
});

add_task(async function() {
  Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);

  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
  gTestBrowser = gBrowser.selectedBrowser;

  await promiseTabLoadEvent(
    gBrowser.selectedTab,
    gTestRoot + "plugin_zoom.html"
  );

  // Work around for delayed PluginBindingAttached
  await promiseUpdatePluginBindings(gTestBrowser);
});

// Enlarges the zoom level 4 times and tests that the overlay is
// visible after each enlargement.
add_task(async function() {
  for (let count = 0; count < 4; count++) {
    FullZoom.enlarge();

    // Reload the page
    await promiseTabLoadEvent(
      gBrowser.selectedTab,
      gTestRoot + "plugin_zoom.html"
    );
    await promiseUpdatePluginBindings(gTestBrowser);
    await SpecialPowers.spawn(gTestBrowser, [{ count }], async function(args) {
      let doc = content.document;
      let plugin = doc.getElementById("test");
      let overlay = plugin.openOrClosedShadowRoot.getElementById("main");
      Assert.ok(
        overlay &&
          !overlay.classList.contains("visible") &&
          overlay.getAttribute("blockall") == "blockall",
        "Overlay should be present for zoom change count " + args.count
      );
    });
  }
});