question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Received `postMessage` for "undefined" but the method doesn't exist

See original GitHub issue

Expected 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

https://bitbucket.org/atlassian/simple-xdm/addon/pipelines/home#!/results/{cc56070d-5ec1-43f2-ab8e-07cf4e6309a5}

  • Karma version (output of karma --version): 1.1.1
  • Relevant part of your karma.config.js file N/A

Steps to reproduce the behaviour

  1. Write test that uses postMessage
  2. Run test with karma
  3. Karma receives postMessage it doesn’t expect and balks

Consider changing log to warn rather than error or namespacing your postMessages

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
twolfsoncommented, Jul 12, 2016

Ah, damn. Sorry for my ignorance on that. Maybe we should move from data.method to data.__karma_method as a magic key (to prevent issues where an application might use data.method as well) and remove the assertion (or drop it to a console.warn) to prevent throwing errors with other programs using postMessage at all.

0reactions
twolfsoncommented, Jul 13, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found