summaryrefslogtreecommitdiffstats
path: root/dom/html/test/forms/test_input_color_picker_initial.html
blob: c7467c752033a00bde68e52082622a6a0a5fc3a6 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=885996
-->
<head>
  <meta charset="utf-8">
  <title>Test for Bug 1234567</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="/tests/SimpleTest/EventUtils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <script type="application/javascript">

  /** Test that the initial value of the nsIColorPicker is the current value of
      the <input type='color'> element. **/

  SimpleTest.waitForExplicitFinish();

  var MockColorPicker = SpecialPowers.MockColorPicker;

  var test = runTest();

  SimpleTest.waitForFocus(function() {
    test.next();
  });

  function* runTest() {
    MockColorPicker.init(window);
    var element = null;

    MockColorPicker.showCallback = function(picker) {
      is(picker.initialColor, element.value);
      SimpleTest.executeSoon(function() {
        test.next();
      });
      return "";
    };

    for (var i = 0; i < document.getElementsByTagName('input').length; ++i) {
      element = document.getElementsByTagName('input')[i];
      if (element.parentElement.id === 'dynamic-values') {
        element.value = '#deadbe';
      }
      synthesizeMouseAtCenter(element, {});
      yield undefined;
    };

    MockColorPicker.cleanup();
    SimpleTest.finish();
  }

  </script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=885996">Mozilla Bug 885996</a>
<p id="display"></p>
<div id="content">
  <div id='valid-values'>
    <input type='color' value='#ff00ff'>
    <input type='color' value='#ab3275'>
    <input type='color' value='#abcdef'>
    <input type='color' value='#ABCDEF'>
  </div>
  <div id='invalid-values'>
    <input type='color' value='ffffff'>
    <input type='color' value='#abcdez'>
    <input type='color' value='#0123456'>
  </div>
  <div id='dynamic-values'>
    <input type='color' value='#ab4594'>
    <input type='color' value='#984534'>
    <input type='color' value='#f8b9a0'>
  </div>
</div>
<pre id="test">
</pre>
</body>
</html>