blob: ed820d0e66558d1db01109a6c4227c960f15644b [file] [edit]
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Element Timing: do NOT observe cross-origin images</title>
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/element-timing-helpers.js"></script>
<script>
async_test((t) => {
const observer = new PerformanceObserver(
t.step_func_done((entryList) => {
assert_unreached("We should not observe a cross origin element.");
})
);
observer.observe({entryTypes: ['element']});
// We add the image during onload to be sure that the observer is registered
// in time for it to observe the element timing.
// TODO(npm): change observer to use buffered flag.
window.onload = t.step_func(() => {
// Add a cross origin image resource.
const img = document.createElement('img');
img.src = 'http://{{domains[www]}}:{{ports[http][1]}}'
+ '/element-timing/resources/square100.png';
img.setAttribute('elementtiming', 'my_image');
img.onload = t.step_func(() => {
t.step_timeout( () => {
// After some wait, assume observer did not receive the entry, so the test passes.
t.done();
}, 100);
});
document.body.appendChild(img);
});
}, 'Cross-origin image element is NOT observable.');
</script>
</body>