Received `postMessage` for "undefined" but the method doesn't exist
See original GitHub issueExpected behavior
Projects that use postMessage should not break karma
Actual behavior
This change makes karma incompatible with projects that use postMessage https://github.com/karma-runner/karma/commit/81b1f04c70eb14ca675f60b3f374bb50b96d80fe#diff-e935b6c040afc12b7a014e625f4f0cedR40
Enviroment Details
- Karma version (output of
karma --version
): 1.1.1 - Relevant part of your
karma.config.js
file N/A
Steps to reproduce the behaviour
- Write test that uses postMessage
- Run test with karma
- Karma receives postMessage it doesn’t expect and balks
Consider changing log to warn rather than error or namespacing your postMessages
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:10 (8 by maintainers)
Top Results From Across the Web
postMessage() generates error "undefined is not a function"
postMessage () generates error "undefined is not a function" · postMessage is a method of Window object, whereas $('.editor') is a jQuery object....
Read more >Window.postMessage() - Web APIs | MDN
The window.postMessage() method safely enables cross-origin communication between Window objects; e.g., between a page and a pop-up that it ...
Read more >window.ReactNativeWebView.postMessage causes error on ...
The communication between react native side and webview are all fine. But I got this error when opened website with PC browser.
Read more >Cross-window communication - The Modern JavaScript Tutorial
The window that wants to send a message calls postMessage method of the receiving window. In other words, if we want to send...
Read more >9.3 Cross-document messaging - HTML Standard - WhatWG
The Window interface's postMessage( message , options ) method steps ... object must not be garbage collected while there exists an event ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, damn. Sorry for my ignorance on that. Maybe we should move from
data.method
todata.__karma_method
as a magic key (to prevent issues where an application might usedata.method
as well) and remove the assertion (or drop it to aconsole.warn
) to prevent throwing errors with other programs usingpostMessage
at all.I took a shot at a test but wasn’t able to get it working and ran out of time. However, I have completed a patch and will be submitting a PR shortly.