Skip to content

Instantly share code, notes, and snippets.

@dtapuska
dtapuska / gist:bd92755849991c2fd9b87e1d46691321
Created August 23, 2018 16:07
PostMessage equivalence
worker.postMessage('example', {transfer: [a,b]});
will be equivalent to
worker.postMessage('example', [a, b]);
window.postMessage('example', 'http://example.com');
will be equivalent to
window.postMessage('example', {targetOrigin: 'http://example.com'});
(function(){
function getElementXPath(element) {
if (element && element.id)
return '//*[@id="' + element.id + '"]';
else
return getElementTreeXPath(element);
}
function getElementTreeXPath(element) {
var paths = [];