1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/webcomponents/test_document_register_base_queue.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,48 @@ 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 lifecycle callback</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 +var p = Object.create(HTMLElement.prototype); 1.15 + 1.16 +var createdCallbackCallCount = 0; 1.17 + 1.18 +// By the time the base element queue is processed via the microtask, 1.19 +// both x-hello elements should be in the document. 1.20 +p.createdCallback = function() { 1.21 + var one = document.getElementById("one"); 1.22 + var two = document.getElementById("two"); 1.23 + isnot(one, null, "First x-hello element should be in the tree."); 1.24 + isnot(two, null, "Second x-hello element should be in the tree."); 1.25 + createdCallbackCallCount++; 1.26 + if (createdCallbackCallCount == 2) { 1.27 + SimpleTest.finish(); 1.28 + } 1.29 + 1.30 + if (createdCallbackCallCount > 2) { 1.31 + ok(false, "Created callback called too much."); 1.32 + } 1.33 +}; 1.34 + 1.35 +p.attributeChangedCallback = function(name, oldValue, newValue) { 1.36 + ok(false, "Attribute changed callback should not be called because callbacks should not be queued until created callback invoked."); 1.37 +}; 1.38 + 1.39 +document.registerElement("x-hello", { prototype: p }); 1.40 + 1.41 +SimpleTest.waitForExplicitFinish(); 1.42 +</script> 1.43 +</head> 1.44 +<body> 1.45 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=783129">Bug 783129</a> 1.46 +<x-hello id="one"></x-hello> 1.47 +<x-hello id="two"></x-hello> 1.48 +<script> 1.49 +</script> 1.50 +</body> 1.51 +</html>