1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/general/browser_bug581947.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,90 @@ 1.4 +function check(aElementName, aBarred) { 1.5 + let doc = gBrowser.contentDocument; 1.6 + let tooltip = document.getElementById("aHTMLTooltip"); 1.7 + let content = doc.getElementById('content'); 1.8 + 1.9 + let e = doc.createElement(aElementName); 1.10 + content.appendChild(e); 1.11 + 1.12 + ok(!tooltip.fillInPageTooltip(e), 1.13 + "No tooltip should be shown when the element is valid"); 1.14 + 1.15 + e.setCustomValidity('foo'); 1.16 + if (aBarred) { 1.17 + ok(!tooltip.fillInPageTooltip(e), 1.18 + "No tooltip should be shown when the element is barred from constraint validation"); 1.19 + } else { 1.20 + ok(tooltip.fillInPageTooltip(e), 1.21 + e.tagName + " " +"A tooltip should be shown when the element isn't valid"); 1.22 + } 1.23 + 1.24 + e.setAttribute('title', ''); 1.25 + ok (!tooltip.fillInPageTooltip(e), 1.26 + "No tooltip should be shown if the title attribute is set"); 1.27 + 1.28 + e.removeAttribute('title'); 1.29 + content.setAttribute('novalidate', ''); 1.30 + ok (!tooltip.fillInPageTooltip(e), 1.31 + "No tooltip should be shown if the novalidate attribute is set on the form owner"); 1.32 + content.removeAttribute('novalidate'); 1.33 + 1.34 + content.removeChild(e); 1.35 +} 1.36 + 1.37 +function todo_check(aElementName, aBarred) { 1.38 + let doc = gBrowser.contentDocument; 1.39 + let tooltip = document.getElementById("aHTMLTooltip"); 1.40 + let content = doc.getElementById('content'); 1.41 + 1.42 + let e = doc.createElement(aElementName); 1.43 + content.appendChild(e); 1.44 + 1.45 + let cought = false; 1.46 + try { 1.47 + e.setCustomValidity('foo'); 1.48 + } catch (e) { 1.49 + cought = true; 1.50 + } 1.51 + 1.52 + todo(!cought, "setCustomValidity should exist for " + aElementName); 1.53 + 1.54 + content.removeChild(e); 1.55 +} 1.56 + 1.57 +function test () { 1.58 + waitForExplicitFinish(); 1.59 + gBrowser.selectedTab = gBrowser.addTab(); 1.60 + gBrowser.selectedBrowser.addEventListener("load", function () { 1.61 + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); 1.62 + 1.63 + let testData = [ 1.64 + /* element name, barred */ 1.65 + [ 'input', false ], 1.66 + [ 'textarea', false ], 1.67 + [ 'button', true ], 1.68 + [ 'select', false ], 1.69 + [ 'output', true ], 1.70 + [ 'fieldset', true ], 1.71 + [ 'object', true ], 1.72 + ]; 1.73 + 1.74 + for each (let data in testData) { 1.75 + check(data[0], data[1]); 1.76 + } 1.77 + 1.78 + let todo_testData = [ 1.79 + [ 'keygen', 'false' ], 1.80 + ]; 1.81 + 1.82 + for each(let data in todo_testData) { 1.83 + todo_check(data[0], data[1]); 1.84 + } 1.85 + 1.86 + gBrowser.removeCurrentTab(); 1.87 + finish(); 1.88 + }, true); 1.89 + 1.90 + content.location = 1.91 + "data:text/html,<!DOCTYPE html><html><body><form id='content'></form></body></html>"; 1.92 +} 1.93 +