Skip to content

Commit

Permalink
Added test for postMessage structured clones. fixes #388
Browse files Browse the repository at this point in the history
  • Loading branch information
gregersrygg committed Jul 16, 2018
1 parent 232e23b commit 6b1ff98
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions feature-detects/postmessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@
"caniuse": "x-doc-messaging",
"notes": [{
"name": "W3C Spec",
"href": "https://www.w3.org/TR/html5/comms.html#posting-messages"
"href": "https://www.w3.org/TR/webmessaging/#crossDocumentMessages"
}],
"polyfills": ["easyxdm", "postmessage-jquery"]
"polyfills": ["easyxdm", "postmessage-jquery"],
"knownBugs": ["structuredclones - Android 2&3 can not send a structured clone of dates, filelists or regexps"],
"warnings": ["Some old WebKit versions have bugs. Stick with object, array, number and pixeldata to be safe."]
}
!*/
/* DOC
Detects support for the `window.postMessage` protocol for cross-document messaging.
`Modernizr.postmessage.structuredclones` reports if `postMessage` can send objects.
*/
define(['Modernizr'], function(Modernizr) {
Modernizr.addTest('postmessage', 'postMessage' in window);
define(['Modernizr'], function( Modernizr ) {
var support = new Boolean('postMessage' in window);
support.structuredclones = true;

try {
window.postMessage({ toString: function () { support.structuredclones = false; } }, '*');
} catch (e) {}

Modernizr.addTest('postmessage', support);
});

0 comments on commit 6b1ff98

Please sign in to comment.