Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): Prevent inheritable styles from affecting rikaikun #958

Merged
merged 2 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions extension/css/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,10 @@ table {
color: inherit;
}

#rikaikun-shadow {
all: initial;
}

/* Supported starting in Chrome 84 */
@supports (all: revert) {
#rikaikun-shadow {
all: revert;
}
}

/* Need duplicate selector for gracefully handling reset. */
/* stylelint-disable-next-line no-duplicate-selectors */
#rikaikun-shadow {
all: initial;
background: var(--primary-background-color);
border: 1px solid #d0d0d0;
border-radius: 5px;
Expand Down
20 changes: 20 additions & 0 deletions extension/test/e2e_visual_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,26 @@ describe('Visual Regression Tests', function () {
});
});
});

it('should render correctly,ignoring external styles', async function () {
const clock = sinon.useFakeTimers();
const span = insertHtmlIntoDomAndReturnFirstTextNode(
'<span>あいたくない</span>'
) as HTMLSpanElement;
const style = document.createElement('style');
style.id = 'test-id';
style.textContent =
'body { text-align: center; } div { text-decoration: underline; !important}';
document.head.appendChild(style);

await triggerMousemoveAtElementStart(span);
// Tick the clock forward to account for the popup delay.
clock.tick(150);
await waitForVisiblePopup();

await takeSnapshot('ignoring-external-styles');
style.remove();
});
});

async function toggleRikaikun() {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.