<!DOCTYPE html>
<script src="../../resources/js-test-pre.js"></script>
<script>

description('Tests that lookup in inline event handlers keeps references alive');

function dispatchClick(element)
{
    var clickEvent = document.createEvent('MouseEvent');
    clickEvent.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0,false, false, false, false, 0, null);
    element.dispatchEvent(clickEvent);
}

var result;
var custom = 'FAIL';

var div1 = document.createElement('div');
div1.custom = 'PASS';
div1.setAttribute('onclick', 'result = custom');

var div2 = document.createElement('div');
div2.onclick = div1.onclick;

div1 = null;
gc();

dispatchClick(div2);
shouldBeEqualToString('result', 'PASS');

</script>
<script src="../../resources/js-test-post.js"></script>