Created
January 11, 2019 15:43
-
-
Save elbart/72d8d86df034e15021567cd203293bb5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Child Domain</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.0/js.cookie.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jschannel/1.0.0-git-commit1-8c4f7eb/jschannel.min.js"></script> | |
</head> | |
<body> | |
<button onClick="onLoginClick()">Login</button> | |
<script type="text/javascript"> | |
var chan = Channel.build({ | |
window: window.parent, | |
origin: "*", | |
scope: "testScope" | |
}); | |
let onLoginClick = function(trans, params) { | |
document.hasStorageAccess().then(hasAccess => { | |
if (!hasAccess) { | |
console.log("no access - requesting access"); | |
return document.requestStorageAccess(); | |
} | |
}).then(_ => { | |
document.hasStorageAccess().then(hasAccess => { | |
console.log("hasAccess:", hasAccess); | |
window.localStorage.setItem('foo', 'bar'); | |
}) | |
}).catch((err) => { | |
console.log("hasStorageAccess() failed", err); | |
}); | |
}; | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Parent Domain</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.0/js.cookie.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jschannel/1.0.0-git-commit1-8c4f7eb/jschannel.min.js"></script> | |
</head> | |
<body> | |
<div> | |
Cookies: <ul class="cookie-data"></ul> | |
</div> | |
<iframe | |
id="rpc-gateway" | |
src="http://child.local:8080/iframe-firefox.html" | |
sandbox="allow-storage-access-by-user-activation allow-scripts allow-same-origin"></iframe> | |
<script type="text/javascript"> | |
var chan = Channel.build({ | |
window: document.getElementById("rpc-gateway").contentWindow, | |
origin: "*", | |
scope: "testScope" | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment