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

Unified Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/custom-elements/v0/custom-element-lifecycle/types-of-callbacks/attribute-changed-callback-remove-attribute-test.html

Issue 1984023002: Move web-platform-tests to wpt (part 1 of 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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: third_party/WebKit/LayoutTests/imported/web-platform-tests/custom-elements/v0/custom-element-lifecycle/types-of-callbacks/attribute-changed-callback-remove-attribute-test.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/custom-elements/v0/custom-element-lifecycle/types-of-callbacks/attribute-changed-callback-remove-attribute-test.html b/third_party/WebKit/LayoutTests/imported/web-platform-tests/custom-elements/v0/custom-element-lifecycle/types-of-callbacks/attribute-changed-callback-remove-attribute-test.html
deleted file mode 100644
index 2678714b496020f8448cd14bb697c400790c2655..0000000000000000000000000000000000000000
--- a/third_party/WebKit/LayoutTests/imported/web-platform-tests/custom-elements/v0/custom-element-lifecycle/types-of-callbacks/attribute-changed-callback-remove-attribute-test.html
+++ /dev/null
@@ -1,166 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<title>Test attribute removing to check attributeChanged callback of a custom element</title>
-<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
-<meta name="assert" content="attributeChanged callback must be enqueued whenever custom element's attribute is removed">
-<link rel="help" href="http://www.w3.org/TR/custom-elements/#types-of-callbacks">
-<script src="../../../../../../resources/testharness.js"></script>
-<script src="../../../../../../resources/testharnessreport.js"></script>
-<script src="../../testcommon.js"></script>
-</head>
-<body>
-<div id="log"></div>
-<script>
-test(function() {
- var doc = newHTMLDocument();
- var proto = newHTMLElementPrototype();
- var GeneratedConstructor = doc.registerElement('x-a', {prototype: proto});
-
- var customElement = new GeneratedConstructor();
- //attributeChangedCallback should be called the first time here
- customElement.setAttribute('class', 'someClass');
- //attributeChangedCallback should be called the second time here
- customElement.removeAttribute('class');
- assert_equals(proto.attributeChangedCallbackCalledCounter, 2, 'Callback attributeChanged should be called ' +
- 'after setAttribute() and removeAttribute() calls');
-}, 'Test attributeChanged callback if attribute is removed. ' +
- 'The custom element created via constructor');
-
-
-test(function() {
- var doc = newHTMLDocument();
- HTML5_ELEMENTS.forEach(function(element) {
- var obj = doc.createElement(element);
- var proto = newCustomElementPrototype(obj.constructor.prototype);
- var GeneratedConstructor = doc.registerElement('x-' + element + '-' + element + '-1', {
- prototype: proto,
- extends: element
- });
-
- var customElement = new GeneratedConstructor();
- //attributeChangedCallback should be called the first time here
- customElement.setAttribute('class', 'someClass');
- //attributeChangedCallback should be called the second time here
- customElement.removeAttribute('class');
- assert_equals(proto.attributeChangedCallbackCalledCounter, 2,
- 'Callback attributeChanged should be called ' +
- 'after setAttribute() and removeAttribute() calls for "' + element + '"');
- });
-}, 'Test attributeChanged callback if attribute is removed. ' +
- 'The custom element created via constructor and extends HTML element');
-
-
-test(function() {
- var doc = newHTMLDocument();
- var proto = newHTMLElementPrototype();
- doc.registerElement('x-b', {prototype: proto});
-
- doc.body.innerHTML = '<x-b id="x-b" class="theClass"></x-b>';
- var customElement = doc.querySelector('#x-b');
- customElement.removeAttribute('class');
- assert_equals(proto.attributeChangedCallbackCalledCounter, 1,
- 'Callback attributeChanged should be called ' +
- 'after removeAttribute() call');
-}, 'Test attributeChanged callback if attribute is removed. ' +
- 'The custom element created via innerHTML property');
-
-
-test(function() {
- var doc = newHTMLDocument();
- var proto = newHTMLElementPrototype();
- doc.registerElement('x-c', {prototype: proto});
-
- doc.body.innerHTML = '<x-c id="x-c" class="theClass"></x-c>';
- var customElement = doc.querySelector('#x-c');
- customElement.removeAttribute('class');
- assert_equals(proto.attributeChangedCallbackArgs[2], null,
- 'Removing an attribute should invoke ' +
- 'the attributeChanged callback with a null new value');
- assert_array_equals(proto.attributeChangedCallbackArgs,
- ['class', 'theClass', null],
- 'Unexpected attributeChanged callback arguments');
-}, 'Test attributeChanged callback arguments if attribute is removed. ' +
- 'The custom element created via innerHTML property');
-
-
-test(function() {
- var doc = newHTMLDocument();
- var proto = newHTMLElementPrototype();
-
- doc.body.innerHTML = '<x-d id="x-d" class="theClass"></x-d>';
- var customElement = doc.querySelector('#x-d');
- // this should not call or enqueue attributeChangedCallback
- customElement.setAttribute('class', 'someClass');
- // this one should not too
- customElement.removeAttribute('class');
- assert_equals(proto.attributeChangedCallbackCalledCounter, 0,
- 'Callback attributeChanged should not be called');
-
- doc.registerElement('x-d', {prototype: proto});
- // this call invokes attributeChangedCallback
- customElement.setAttribute('name', 'someName');
- // and this one
- customElement.removeAttribute('name');
- assert_equals(proto.attributeChangedCallbackCalledCounter, 2,
- 'Callback attributeChanged should be called ' +
- 'after setAttribute() and removeAttribute() calls');
-}, 'Test attributeChanged callback is not called if attribute is removed. ' +
- 'The custom element created via innerHTML property and unresolved at first');
-
-
-testInIFrame('../../resources/x-element.html', function(doc) {
- var proto = newHTMLElementPrototype();
- doc.registerElement('x-element', {prototype: proto});
-
- var customElement = doc.querySelector('#x-element');
- customElement.setAttribute('class', 'someClass');
- customElement.removeAttribute('class');
- assert_equals(proto.attributeChangedCallbackCalledCounter, 2,
- 'Callback attributeChanged should be called ' +
- 'after setAttribute() and removeAttribute() calls');
-}, 'Test attributeChanged callback is called if attribute is removed. ' +
- 'The custom element created via constructor and the document has browsing context');
-
-
-testInIFrame('../../resources/x-element.html', function(doc) {
- var proto = newHTMLElementPrototype();
- doc.registerElement('x-element', {prototype: proto});
-
- doc.body.innerHTML = '<x-element id="x-element" class="theClass"></x-element>';
- var customElement = doc.querySelector('#x-element');
- customElement.removeAttribute('class');
- assert_equals(proto.attributeChangedCallbackArgs[2], null,
- 'Removing an attribute should invoke ' +
- 'the attributeChanged callback with a null new value');
- assert_array_equals(proto.attributeChangedCallbackArgs,
- ['class', 'theClass', null],
- 'Unexpected attributeChanged callback arguments');
-}, 'Test attributeChanged callback arguments if attribute is removed. ' +
- 'The custom element created via innerHTML property and the document has browsing context');
-
-
-testInIFrame('../../resources/x-element.html', function(doc) {
- var customElement = doc.querySelector('#x-element');
- // this should not call or enqueue attributeChangedCallback
- customElement.setAttribute('name', 'someName');
- // this one too
- customElement.removeAttribute('name');
-
- var proto = newHTMLElementPrototype();
- doc.registerElement('x-element', {prototype: proto});
- assert_equals(proto.attributeChangedCallbackCalledCounter, 0,
- 'Callback attributeChanged should not be called');
- // this call invokes attributeChangedCallback
- customElement.setAttribute('class', 'someClass');
- // this call invokes attributeChangedCallback at second time
- customElement.removeAttribute('class');
- assert_equals(proto.attributeChangedCallbackCalledCounter, 2,
- 'Callback attributeChanged should be called ' +
- 'after setAttribute() and removeAttribute() calls');
-}, 'Test attributeChanged callback if attribute is removed. ' +
- 'The custom element created via innerHTML property and unresolved at first. ' +
- 'The document has browsing context');
-</script>
-</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698