blob: 65e131f445a409ddff840cad7d98c449d1bca042 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>Dataset - Delete</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Dataset - Delete</h1>
<div id="log"></div>
<script>
function testDelete(attr, prop)
{
var d = document.createElement("div");
d.setAttribute(attr, "value");
delete d.dataset[prop];
return d.hasAttribute(attr) === false && d.getAttribute(attr) != "value";
}
function testDeleteNoAdd(prop)
{
var d = document.createElement("div");
delete d.dataset[prop];
return true;
}
test(function() { assert_true(testDelete('data-foo', 'foo')); },
"Deleting element.dataset['foo'] should also remove an attribute with name 'data-foo' should it exist.");
test(function() { assert_true(testDelete('data-foo-bar', 'fooBar')); },
"Deleting element.dataset['fooBar'] should also remove an attribute with name 'data-foo-bar' should it exist.");
test(function() { assert_true(testDelete('data--', '-')); },
"Deleting element.dataset['-'] should also remove an attribute with name 'data--' should it exist.");
test(function() { assert_true(testDelete('data--foo', 'Foo')); },
"Deleting element.dataset['Foo'] should also remove an attribute with name 'data--foo' should it exist.");
test(function() { assert_true(testDeleteNoAdd('data--foo', '-foo')); },
"Deleting element.dataset['-foo'] should also remove an attribute with name 'data--foo' should it exist.");
test(function() { assert_true(testDelete('data---foo', '-Foo')); },
"Deleting element.dataset['-Foo'] should also remove an attribute with name 'data---foo' should it exist.");
test(function() { assert_true(testDelete('data-', '')); },
"Deleting element.dataset[''] should also remove an attribute with name 'data-' should it exist.");
test(function() { assert_true(testDelete('data-\xE0', '\xE0')); },
"Deleting element.dataset['\xE0'] should also remove an attribute with name 'data-\xE0' should it exist.");
test(function() { assert_true(testDeleteNoAdd('foo')); },
"Deleting element.dataset['foo'] should not throw if even if the element does now have an attribute with the name data-foo.");
</script>
</body>
</html>