dom/tests/mochitest/webcomponents/test_document_register_parser.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/webcomponents/test_document_register_parser.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,47 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=783129
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for document.registerElement for elements created by the parser</title>
    1.11 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.13 +<script>
    1.14 +
    1.15 +var extendedButtonProto = Object.create(HTMLButtonElement.prototype);
    1.16 +var buttonCallbackCalled = false;
    1.17 +extendedButtonProto.createdCallback = function() {
    1.18 +  is(buttonCallbackCalled, false, "created callback for x-button should only be called once.");
    1.19 +  is(this.tagName, "BUTTON", "Only the <button> element should be upgraded.");
    1.20 +  buttonCallbackCalled = true;
    1.21 +};
    1.22 +
    1.23 +document.registerElement("x-button", { prototype: extendedButtonProto, extends: "button" });
    1.24 +
    1.25 +var divProto = Object.create(HTMLDivElement.prototype);
    1.26 +var divCallbackCalled = false;
    1.27 +divProto.createdCallback = function() {
    1.28 +  is(divCallbackCalled, false, "created callback for x-div should only be called once.");
    1.29 +  is(buttonCallbackCalled, true, "crated callback should be called for x-button before x-div.");
    1.30 +  is(this.tagName, "X-DIV", "Only the <x-div> element should be upgraded.");
    1.31 +  divCallbackCalled = true;
    1.32 +  SimpleTest.finish();
    1.33 +};
    1.34 +
    1.35 +document.registerElement("x-div", { prototype: divProto });
    1.36 +
    1.37 +SimpleTest.waitForExplicitFinish();
    1.38 +</script>
    1.39 +</head>
    1.40 +<body>
    1.41 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=783129">Bug 783129</a>
    1.42 +<button is="x-button"></button><!-- should be upgraded -->
    1.43 +<x-button></x-button><!-- should not be upgraded -->
    1.44 +<span is="x-button"></span><!-- should not be upgraded -->
    1.45 +<div is="x-div"></div><!-- should not be upgraded -->
    1.46 +<x-div></x-div><!-- should be upgraded -->
    1.47 +<script>
    1.48 +</script>
    1.49 +</body>
    1.50 +</html>

mercurial