Skip to content

Commit

Permalink
WebUI: Add cr-dialog tests to ensure 'close' and 'cancel' events are …
Browse files Browse the repository at this point in the history
…bubbling.

This is in preparation for migrating to Polymer2, which uses Shadow DOM v1,
which changed the bubbling behavior of various events to not bubble. These
tests will fail in v1, without additional changes to cr-dialog itself.

Bug: 848518
Change-Id: I5eb7c7c1c1c5eae325649d50952299f4d84337ef
Reviewed-on: https://chromium-review.googlesource.com/1081668
Reviewed-by: Hector Carmona <hcarmona@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#563479}
  • Loading branch information
freshp86 authored and Commit Bot committed Jun 1, 2018
1 parent b8db517 commit cd079f3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions chrome/test/data/webui/cr_elements/cr_dialog_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,34 @@ suite('cr-dialog', function() {
PolymerTest.clearBody();
});

test('close event bubbles', function() {
document.body.innerHTML = `
<cr-dialog>
<div slot="title">title</div>
<div slot="body">body</div>
</cr-dialog>`;

const dialog = document.body.querySelector('cr-dialog');
dialog.showModal();
const whenFired = test_util.eventToPromise('close', dialog);
dialog.close();
return whenFired;
});

test('cancel event bubbles', function() {
document.body.innerHTML = `
<cr-dialog>
<div slot="title">title</div>
<div slot="body">body</div>
</cr-dialog>`;

const dialog = document.body.querySelector('cr-dialog');
dialog.showModal();
const whenFired = test_util.eventToPromise('cancel', dialog);
dialog.cancel();
return whenFired;
});

test('focuses title on show', function() {
document.body.innerHTML = `
<cr-dialog>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ CrElementsDialogTest.prototype = {

/** @override */
extraLibraries: CrElementsBrowserTest.prototype.extraLibraries.concat([
'../settings/test_util.js',
'cr_dialog_test.js',
]),
};
Expand Down

0 comments on commit cd079f3

Please sign in to comment.