Integrate media query evaluation into HTML5 event loop
[WebKit-https.git] / LayoutTests / fast / events / bogus-dropEffect-effectAllowed.html
1 <html>
2 <head>
3 <script src="../../resources/js-test-pre.js"></script>
4 <style>
5 #dropTarget, #dragMe { text-align: center; display: table-cell; vertical-align: middle }
6 #dropTarget {width: 256px; height: 256px; border: 1px dashed}
7 #dragMe {-webkit-user-drag: element; -webkit-user-select: none; background: #ff0000; width: 64px; height: 64px; color: white}
8 </style>
9 <script>
10     var dragMe;
11     var dropTarget;
12     var effectAllowedElem;
13     var dropEffectElem;
14     var consoleElm;
15     var event;
16     
17     window.onload = function()
18     {
19         dragMe = document.getElementById("dragMe");
20         dropTarget = document.getElementById("dropTarget");
21         consoleElm = document.getElementById("console");
22         
23         if (!dragMe || !dropTarget || !consoleElm)
24             return;
25         
26         dragMe.ondragstart = dragStart;
27         dragMe.ondragend = dragEnd;
28         
29         dropTarget.ondragenter = dragEntered;
30         dropTarget.ondragover = dragOver;
31         dropTarget.ondrop = drop;
32         
33         runTest();
34     }
35     
36     function dragStart(e)
37     {
38         var validEffectAllowedList = ["all", "copy", "copyLink", "copyMove", "link", "linkMove", "move", "none", "uninitialized"];
39         var effectAllowedListToTest = ["all", "copy", "bogus", "copyLink", "wrong", "copyMove", "linkCopyMove", "link",
40             "linkMove", "move", "none", "uninitialized", "dummy", "bogus", "fake", "illegal"];
41         
42         event = e;
43         
44         for (var i = 0; i < effectAllowedListToTest.length; i++) {
45             var effectAllowedBefore = e.dataTransfer.effectAllowed;
46             e.dataTransfer.effectAllowed = effectAllowedListToTest[i];
47             if (validEffectAllowedList.indexOf(effectAllowedListToTest[i]) != -1)
48                 shouldBeEqualToString("event.dataTransfer.effectAllowed", effectAllowedListToTest[i]);
49             else
50                 shouldBeEqualToString("event.dataTransfer.effectAllowed", effectAllowedBefore);
51         }
52         
53         e.dataTransfer.setData('Text', e.target.textContent);
54     }
55     
56     function dragEnd(e)
57     {
58         return;
59     }
60     
61     function dragEntered(e)
62     {
63         dragEnteredAndUpdated(e);
64     }
65     
66     function dragOver(e)
67     {
68         dragEnteredAndUpdated(e);
69     }
70     
71     function dragEnteredAndUpdated(e)
72     {
73         var validDropEffectList = ["none", "copy", "link", "move", "link"];
74         var dropEffectListToTest = ["all", "copy", "bogus", "copyLink", "wrong", "copyMove", "linkCopyMove", "link",
75             "linkMove", "move", "none", "uninitialized", "dummy", "bogus", "fake", "illegal"];
76         
77         event = e;
78         
79         for (var i = 0; i < dropEffectListToTest.length; i++) {
80             var dropEffectBefore = e.dataTransfer.dropEffect;
81             e.dataTransfer.dropEffect = dropEffectListToTest[i];
82
83             if (validDropEffectList.indexOf(dropEffectListToTest[i]) != -1)
84                 shouldBeEqualToString("event.dataTransfer.dropEffect", dropEffectListToTest[i]);
85             else
86                 shouldBeEqualToString("event.dataTransfer.dropEffect", dropEffectBefore);
87
88         }
89
90         cancelDrag(e);
91     }
92     
93     function drop(e)
94     {
95         cancelDrag(e);
96     }
97     
98     function cancelDrag(e)
99     {
100         e.preventDefault();
101     }
102
103     function runTest()
104     {
105         if (!window.eventSender)
106             return;
107             
108         if (window.testRunner)
109             testRunner.dumpAsText();
110             
111         var startX = dragMe.offsetLeft + 10;
112         var startY = dragMe.offsetTop + dragMe.offsetHeight / 2;
113         var endX = dropTarget.offsetLeft + 10;
114         var endY = dropTarget.offsetTop + dropTarget.offsetHeight / 2;
115         
116         eventSender.mouseMoveTo(startX, startY);
117         eventSender.mouseDown();
118         eventSender.leapForward(100);
119         eventSender.mouseMoveTo(endX, endY);
120         eventSender.mouseUp();
121
122         var testContainer = document.getElementById("test-container");
123         if (testContainer)
124             document.body.removeChild(testContainer);
125         debug('<br /><span class="pass">TEST COMPLETE</span>');
126     }
127 </script>
128 </head>
129 <body>
130     <p id="description"></p>
131     <div id="test-container">
132         <br/><br/>
133         <div id="dropTarget">Drop the red square onto me.<br/><br/></div>
134         <hr/>
135         <p>Items that can be dragged to the drop target:</p>
136         <div id="dragMe" draggable="true">Square</div>
137         <hr/>
138     </div>
139     <div id="console"></div>
140     <script>
141         description("This test checks that effectAllowed and dropEffect cannot be set to values that aren't defined in the spec");
142     </script>
143 </body>
144 </html>