gecko/dom/tests/mochitest/webcomponents/test_document_register_lifecycle.html

50 lines
1.3 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=783129
-->
<head>
<title>Test for document.register lifecycle callback</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script>
var gLifecycleCallbackCalled = false;
var lifecycleCallbacks = {
created: function() {
is(this.getAttribute("id"), "grabme", "|this| value should be the upgrade element");
gLifecycleCallbackCalled = true;
}
};
function startTest() {
var HtmlProto = function() {};
HtmlProto.prototype = HTMLElement.prototype;
// Create a prototype that inheits from HTMLElement.
var customProto = new HtmlProto();
customProto.hello = function() {
ok(true, "Custom element should use provided prototype.");
};
var elementConstructor = document.register("x-hello", { prototype: customProto, lifecycle: lifecycleCallbacks });
ok(gLifecycleCallbackCalled, "Lifecycle callback should be called.");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
</script>
</head>
<body onload="startTest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=783129">Bug 783129</a>
<x-hello id="grabme">
<div id="kid"></div>
</x-hello>
</body>
</html>