Commit b275fdf7 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

Update html/dialog/showmodal-shadow-sibling-frame-crash.html

Convert this test to a testharness test. With CL:823582 this test does
not crash, and does crash prior to that change.

Note: this test uses shadomDOM V0 registerElement and createShadowRoot
since the crash does not reproduce when using shadowDOM V1 methods.

Bug: 789094, 804047
Change-Id: Ia65c2f75b805ed99a7401d5b64110601f917a5d7
Reviewed-on: https://chromium-review.googlesource.com/c/1278456Reviewed-by: default avatarHayato Ito <hayato@chromium.org>
Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599566}
parent beb96b18
CONSOLE WARNING: line 24: document.registerElement is deprecated and will be removed in M73, around March 2019. Please use window.customElements.define instead. See https://www.chromestatus.com/features/4642138092470272 for more details.
CONSOLE WARNING: line 16: Element.createShadowRoot is deprecated and will be removed in M73, around March 2019. Please use Element.attachShadow instead. See https://www.chromestatus.com/features/4507242028072960 for more details.
Test for crash crbug.com/804047 Show custom dialog element
<!DOCTYPE html> <!DOCTYPE html>
<html> <script src="../../resources/testharness.js"></script>
<body> <script src="../../resources/testharnessreport.js"></script>
Test for crash crbug.com/804047 <button>Show custom dialog element</button>
<template id="dialog"> <template>
<custom-dialog></custom-dialog> <custom-dialog></custom-dialog>
</template> </template>
<div></div> <div id=shadow></div>
<iframe></iframe> <iframe id=sibling></iframe>
<script> <script>
var customDialogProto = Object.create(HTMLElement.prototype); async_test(function(test) {
let customDialog = Object.create(HTMLElement.prototype);
customDialogProto.createdCallback = function() {
const shadowRoot = this.createShadowRoot(); customDialog.createdCallback = function() {
shadowRoot.innerHTML = '<dialog></dialog>'; this.createShadowRoot().innerHTML = '<dialog></dialog>';
}; };
customDialogProto.show = function() { customDialog.show = function() {
this.shadowRoot.querySelector('dialog').showModal(); this.shadowRoot.querySelector('dialog').showModal();
}; };
document.registerElement('custom-dialog', { prototype: customDialogProto }); document.registerElement('custom-dialog', {prototype: customDialog});
document.body.querySelector('button').addEventListener('click', function() { onload = test.step_func(() => {
const template = document.querySelector('#dialog'); const template = document.querySelector('template');
const custom = document.importNode(template.content, true); const content = document.importNode(template.content, true);
const dialog = custom.querySelector('custom-dialog'); const dialog = content.querySelector('custom-dialog');
document.querySelector('div').appendChild(dialog); document.querySelector('div').appendChild(dialog);
dialog.show(); dialog.show();
}); test.done();
});
if (window.testRunner) { }, 'Shadow DOM <dialog>.showModal() on a page with an <iframe> should not crash.');
testRunner.dumpAsText();
let absoluteTop = 0;
let absoluteLeft = 0;
const element = document.body.querySelector('button');
for (let parent = element; parent; parent = parent.offsetParent) {
absoluteLeft += parent.offsetLeft;
absoluteTop += parent.offsetTop;
}
const x = absoluteLeft + element.offsetWidth / 2;
const y = absoluteTop + element.offsetHeight / 2;
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.mouseUp();
}
</script> </script>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment