michael@0: function check(aElementName, aBarred) { michael@0: let doc = gBrowser.contentDocument; michael@0: let tooltip = document.getElementById("aHTMLTooltip"); michael@0: let content = doc.getElementById('content'); michael@0: michael@0: let e = doc.createElement(aElementName); michael@0: content.appendChild(e); michael@0: michael@0: ok(!tooltip.fillInPageTooltip(e), michael@0: "No tooltip should be shown when the element is valid"); michael@0: michael@0: e.setCustomValidity('foo'); michael@0: if (aBarred) { michael@0: ok(!tooltip.fillInPageTooltip(e), michael@0: "No tooltip should be shown when the element is barred from constraint validation"); michael@0: } else { michael@0: ok(tooltip.fillInPageTooltip(e), michael@0: e.tagName + " " +"A tooltip should be shown when the element isn't valid"); michael@0: } michael@0: michael@0: e.setAttribute('title', ''); michael@0: ok (!tooltip.fillInPageTooltip(e), michael@0: "No tooltip should be shown if the title attribute is set"); michael@0: michael@0: e.removeAttribute('title'); michael@0: content.setAttribute('novalidate', ''); michael@0: ok (!tooltip.fillInPageTooltip(e), michael@0: "No tooltip should be shown if the novalidate attribute is set on the form owner"); michael@0: content.removeAttribute('novalidate'); michael@0: michael@0: content.removeChild(e); michael@0: } michael@0: michael@0: function todo_check(aElementName, aBarred) { michael@0: let doc = gBrowser.contentDocument; michael@0: let tooltip = document.getElementById("aHTMLTooltip"); michael@0: let content = doc.getElementById('content'); michael@0: michael@0: let e = doc.createElement(aElementName); michael@0: content.appendChild(e); michael@0: michael@0: let cought = false; michael@0: try { michael@0: e.setCustomValidity('foo'); michael@0: } catch (e) { michael@0: cought = true; michael@0: } michael@0: michael@0: todo(!cought, "setCustomValidity should exist for " + aElementName); michael@0: michael@0: content.removeChild(e); michael@0: } michael@0: michael@0: function test () { michael@0: waitForExplicitFinish(); michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: gBrowser.selectedBrowser.addEventListener("load", function () { michael@0: gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); michael@0: michael@0: let testData = [ michael@0: /* element name, barred */ michael@0: [ 'input', false ], michael@0: [ 'textarea', false ], michael@0: [ 'button', true ], michael@0: [ 'select', false ], michael@0: [ 'output', true ], michael@0: [ 'fieldset', true ], michael@0: [ 'object', true ], michael@0: ]; michael@0: michael@0: for each (let data in testData) { michael@0: check(data[0], data[1]); michael@0: } michael@0: michael@0: let todo_testData = [ michael@0: [ 'keygen', 'false' ], michael@0: ]; michael@0: michael@0: for each(let data in todo_testData) { michael@0: todo_check(data[0], data[1]); michael@0: } michael@0: michael@0: gBrowser.removeCurrentTab(); michael@0: finish(); michael@0: }, true); michael@0: michael@0: content.location = michael@0: "data:text/html,
"; michael@0: } michael@0: