Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Unified Diff: LayoutTests/fast/dom/custom/ready-callback.html

Issue 17707002: Implement Custom Elements inserted and removed callbacks. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/dom/custom/ready-callback.html
diff --git a/LayoutTests/fast/dom/custom/ready-callback.html b/LayoutTests/fast/dom/custom/ready-callback.html
index 3ce7e522af09fb303ee0e5182d192dcf4ba4d31b..4cb8680ec0187288337fe589761447be610b429b 100644
--- a/LayoutTests/fast/dom/custom/ready-callback.html
+++ b/LayoutTests/fast/dom/custom/ready-callback.html
@@ -2,33 +2,37 @@
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<body>
+<x-a id="a"></x-a>
+<x-a id="b"></x-a>
<script>
-test(function () {
- var readyInvocations = 0;
- function ready() {
- readyInvocations++;
- }
+t = async_test('ready callback');
+t.calls = [];
- var getterInvocations = 0;
- function getter() {
- getterInvocations++;
- return ready;
- }
+t.step(function () {
+ var proto = Object.create(HTMLElement.prototype);
+ proto.readyCallback = function () {
+ t.calls.push(this.id + ' ready');
+ };
- function failer() {
- assert_unreached('the ready callback must not be retrieved after registration');
- }
-
- var proto = Object.create(HTMLElement.prototype, {
- readyCallback: {
- get: getter
- }
- });
var ctor = document.register('x-a', {prototype: proto});
- assert_equals(getterInvocations, 1, 'the ready callback must have been retrieved');
+ var call_set = t.calls.slice();
+ call_set.sort();
+ assert_array_equals(call_set, ['a ready', 'b ready'], 'document.register must invoke the ready lifecycle callback for upgrade candidates');
+
+ t.calls = [];
+ new ctor();
+ assert_array_equals(t.calls, [' ready'], 'invoking the generated constructor must invoke the ready lifecycle callback');
- proto.readyCallback = failer;
- var element = new ctor();
- assert_equals(readyInvocations, 1, 'the ready callback retrieved at registration must be invoked');
-}, 'transfer ready callback');
+ t.calls = [];
+ var div = document.createElement('div');
+ div.innerHTML = '<x-a id="c"></x-a>';
+ assert_array_equals(t.calls, [], 'parsing this fragment must not synchronously invoke the ready lifecycle callback');
+});
+</script>
+<script>
+t.step(function () {
+ assert_array_equals(t.calls, ['c ready'], 'the ready callback should have been invoked at the microtask checkpoint');
+ t.done();
+ t = null;
+});
</script>

Powered by Google App Engine
This is Rietveld 408576698