mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
399a78ee9f
Some browser extensions, like React DevTools, send messages to the content area. Since our beforeunload event test listens for all messages, it used to catch those as well, failing the test. Add a `source` field to the payload JSON and check for it before treating the message as coming from our own test to make sure the test passes even with such browser extensions installed. Closes gh-5478
22 lines
481 B
HTML
22 lines
481 B
HTML
<!doctype html>
|
|
<html>
|
|
<script src="../../jquery.js"></script>
|
|
<script>
|
|
function report( event ) {
|
|
var payload = {
|
|
source: "jQuery onbeforeunload iframe test",
|
|
event: event.type
|
|
};
|
|
return parent.postMessage( JSON.stringify( payload ), "*" );
|
|
}
|
|
|
|
jQuery( window ).on( "beforeunload", function( event ) {
|
|
report( event );
|
|
} ).on( "load", function( event ) {
|
|
setTimeout( function() {
|
|
window.location.reload();
|
|
}, 50 );
|
|
} );
|
|
</script>
|
|
</html>
|