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

🐛Add computed styles to fake win #26514

Merged
merged 1 commit into from
Jan 28, 2020
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
4 changes: 2 additions & 2 deletions test/unit/test-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ describes.realWin(

it('should ignore unknown script', () => {
expectAsyncConsoleError(
'[runtime] - unknown script: [object HTMLScriptElement] ' +
'[multidoc-manager] - unknown script: [object HTMLScriptElement] ' +
'https://cdn.ampproject.org/other.js'
);

Expand Down Expand Up @@ -1711,7 +1711,7 @@ describes.realWin(

it('should ignore inline script if javascript', () => {
expectAsyncConsoleError(
'[runtime] - unallowed inline javascript: ' +
'[multidoc-manager] - unallowed inline javascript: ' +
'[object HTMLScriptElement]',
2
);
Expand Down
5 changes: 5 additions & 0 deletions testing/fake-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ export class FakeWindow {
* @const
*/
this.requestAnimationFrame = raf;

// Styles.
this.getComputedStyle = function() {
return window.getComputedStyle.apply(window, arguments);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find. Could it be that you want
arguments[0].defaultView instead of window?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe :) arguments[0] is the element here, so I tried arguments[0].ownerDocument.defaultView which points at the fake win, but it throws an Illegal invocation error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be expected to work when the element is from the actual window.

};
}

/** polyfill addEventListener. */
Expand Down