summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/chrome/test_drawWindow_widget_layers.html
blob: 9a1f7503bb7ae57ed7d9ad5be2c2d6b27165e709 (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
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test for canvas drawWindow</title>
  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
  <script type="application/javascript" src="file_drawWindow_common.js"></script>
  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
  <script type="application/javascript">

  SimpleTest.waitForExplicitFinish();
  window.addEventListener("load", openSourceWindow);

  var sourceWindow;

  function openSourceWindow(event) {
    if (event.target != document) {
      return;
    }

    // Add a little bottom padding to the window so that we don't capture the
    // rounded corners at the bottom, which our GL drawing code on OS X draws
    // for regular windows.
    // (The reftest framework doesn't have this problem because it doesn't use
    // a regular window with a titlebar, so there are no rounded corners.)
    const WINDOW_INNER_WIDTH = CANVAS_WIDTH;
    const WINDOW_INNER_HEIGHT = CANVAS_HEIGHT + 10;

    // Need to open as a toplevel chrome window so that
    // DRAWWINDOW_USE_WIDGET_LAYERS is honored.
    sourceWindow = window.browsingContext.topChromeWindow.open("file_drawWindow_source.html", "",
                                                               `chrome,width=${WINDOW_INNER_WIDTH},height=${WINDOW_INNER_HEIGHT}`);
    SimpleTest.waitForFocus(runTests, sourceWindow);
  }

  async function runTests() {
    var cxInterfaceWrap = SpecialPowers.wrap(CanvasRenderingContext2D);
    
    let snapshot = function(context, x, y, width, height, bg) {
      var flags = cxInterfaceWrap.DRAWWINDOW_USE_WIDGET_LAYERS |
                  cxInterfaceWrap.DRAWWINDOW_DRAW_CARET |
                  cxInterfaceWrap.DRAWWINDOW_DRAW_VIEW;
      context.drawWindow(sourceWindow, x, y, width, height, bg, flags);
    }
    await runDrawWindowTests(snapshot, true);

    sourceWindow.close();

    SimpleTest.finish();
  }

  </script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
</body>
</html>