chromium/third_party/blink/web_tests/fast/events/clipboard-clearData.html

<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script>
var testDataTransfer;
function copy(event)
{
    event.preventDefault();

    testDataTransfer = event.clipboardData;
    testDataTransfer.setData('text', 'sample');
    testDataTransfer.setData('url', 'http://www.google.com/');
    testDataTransfer.setData('text/html', '<em>Markup</em>');
    testDataTransfer.setData('custom-data', 'hello world');

    shouldNotThrow('testDataTransfer.clearData(null)'); // Gets converted to "null" string.

    shouldBeEqualToString('testDataTransfer.getData("text")', 'sample');
    shouldBeEqualToString('testDataTransfer.getData("url")', 'http://www.google.com/');
    shouldBeEqualToString('testDataTransfer.getData("text/html")', '<em>Markup</em>');
    shouldBeEqualToString('testDataTransfer.getData("custom-data")', 'hello world');

    shouldNotThrow('testDataTransfer.clearData("custom-data")');
    shouldBeEqualToString('testDataTransfer.getData("text")', 'sample');
    shouldBeEqualToString('testDataTransfer.getData("url")', 'http://www.google.com/');
    shouldBeEqualToString('testDataTransfer.getData("text/html")', '<em>Markup</em>');
    shouldBeEqualToString('testDataTransfer.getData("custom-data")', '');

    shouldNotThrow('testDataTransfer.clearData()');
    shouldBeEqualToString('testDataTransfer.getData("text")', '');
    shouldBeEqualToString('testDataTransfer.getData("url")', '');
    shouldBeEqualToString('testDataTransfer.getData("text/html")', '');
    shouldBeEqualToString('testDataTransfer.getData("custom-data")', '');

    testDataTransfer.setData('text', 'sample');
    testDataTransfer.setData('url', 'http://www.google.com/');
    testDataTransfer.setData('text/html', '<em>Markup</em>');
    testDataTransfer.setData('custom-data', 'hello world');
    // clearData(undefined) is equivalent to clearData().
    shouldNotThrow('testDataTransfer.clearData(undefined)');
    shouldBeEqualToString('testDataTransfer.getData("text")', '');
    shouldBeEqualToString('testDataTransfer.getData("url")', '');
    shouldBeEqualToString('testDataTransfer.getData("text/html")', '');
    shouldBeEqualToString('testDataTransfer.getData("custom-data")', '');
}
</script>
</head>
<body oncopy="copy(event)">
<script>
description("Tests clipboard.clearData()");

document.execCommand('copy');
</script>
</body>
</html>