|
1 function check(aElementName, aBarred) { |
|
2 let doc = gBrowser.contentDocument; |
|
3 let tooltip = document.getElementById("aHTMLTooltip"); |
|
4 let content = doc.getElementById('content'); |
|
5 |
|
6 let e = doc.createElement(aElementName); |
|
7 content.appendChild(e); |
|
8 |
|
9 ok(!tooltip.fillInPageTooltip(e), |
|
10 "No tooltip should be shown when the element is valid"); |
|
11 |
|
12 e.setCustomValidity('foo'); |
|
13 if (aBarred) { |
|
14 ok(!tooltip.fillInPageTooltip(e), |
|
15 "No tooltip should be shown when the element is barred from constraint validation"); |
|
16 } else { |
|
17 ok(tooltip.fillInPageTooltip(e), |
|
18 e.tagName + " " +"A tooltip should be shown when the element isn't valid"); |
|
19 } |
|
20 |
|
21 e.setAttribute('title', ''); |
|
22 ok (!tooltip.fillInPageTooltip(e), |
|
23 "No tooltip should be shown if the title attribute is set"); |
|
24 |
|
25 e.removeAttribute('title'); |
|
26 content.setAttribute('novalidate', ''); |
|
27 ok (!tooltip.fillInPageTooltip(e), |
|
28 "No tooltip should be shown if the novalidate attribute is set on the form owner"); |
|
29 content.removeAttribute('novalidate'); |
|
30 |
|
31 content.removeChild(e); |
|
32 } |
|
33 |
|
34 function todo_check(aElementName, aBarred) { |
|
35 let doc = gBrowser.contentDocument; |
|
36 let tooltip = document.getElementById("aHTMLTooltip"); |
|
37 let content = doc.getElementById('content'); |
|
38 |
|
39 let e = doc.createElement(aElementName); |
|
40 content.appendChild(e); |
|
41 |
|
42 let cought = false; |
|
43 try { |
|
44 e.setCustomValidity('foo'); |
|
45 } catch (e) { |
|
46 cought = true; |
|
47 } |
|
48 |
|
49 todo(!cought, "setCustomValidity should exist for " + aElementName); |
|
50 |
|
51 content.removeChild(e); |
|
52 } |
|
53 |
|
54 function test () { |
|
55 waitForExplicitFinish(); |
|
56 gBrowser.selectedTab = gBrowser.addTab(); |
|
57 gBrowser.selectedBrowser.addEventListener("load", function () { |
|
58 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
|
59 |
|
60 let testData = [ |
|
61 /* element name, barred */ |
|
62 [ 'input', false ], |
|
63 [ 'textarea', false ], |
|
64 [ 'button', true ], |
|
65 [ 'select', false ], |
|
66 [ 'output', true ], |
|
67 [ 'fieldset', true ], |
|
68 [ 'object', true ], |
|
69 ]; |
|
70 |
|
71 for each (let data in testData) { |
|
72 check(data[0], data[1]); |
|
73 } |
|
74 |
|
75 let todo_testData = [ |
|
76 [ 'keygen', 'false' ], |
|
77 ]; |
|
78 |
|
79 for each(let data in todo_testData) { |
|
80 todo_check(data[0], data[1]); |
|
81 } |
|
82 |
|
83 gBrowser.removeCurrentTab(); |
|
84 finish(); |
|
85 }, true); |
|
86 |
|
87 content.location = |
|
88 "data:text/html,<!DOCTYPE html><html><body><form id='content'></form></body></html>"; |
|
89 } |
|
90 |