Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add WPTs for testing the effect on activeElement of the containing do…
…c when calling .focus() and .blur() on an OOP iframe. Differential Revision: https://phabricator.services.mozilla.com/D81497 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1649099 gecko-commit: 05cc29ef24ba11b59afb8954ef23d243f05b2bfd gecko-reviewers: jgraham
- Loading branch information
1 parent
0333bca
commit 90ea6fe
Showing
27 changed files
with
610 additions
and
3 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
focus/activeelement-after-focusing-different-site-iframe-contentwindow.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>activeElement when focusing different-site iframe's contentWindow</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script> | ||
setup({explicit_done:true}); | ||
window.onmessage = function(e) { | ||
var actual = e.data; | ||
test(function() { | ||
// Handle trailing events separately to get make it easier to see | ||
// if they are the only deviation from the expection. | ||
var endedWith = false; | ||
if (actual.endsWith(",willspineventloop,")) { | ||
endedWith = true; | ||
actual += "innerbodyfocus,"; | ||
} | ||
assert_false(endedWith, "Should have gotten innerbodyfocus after willspineventloop"); | ||
}, "Check trailing events"); | ||
test(function() { | ||
// This is a Fission oddity | ||
var endedWith = false; | ||
if (actual.endsWith(",willspineventloop,innerbodyfocus,")) { | ||
endedWith = true; | ||
actual += "innerbodyblur,innerbodyfocus,"; | ||
} | ||
assert_true(endedWith, "Should have gotten innerbodyfocus after willspineventloop"); | ||
}, "Check more trailing events"); | ||
test(function() { | ||
assert_equals(actual, "outeronload,activeElement:BODY,willfocusiframe,didfocusiframe,activeElement:IFRAME,willbluriframe,didbluriframe,activeElement:IFRAME,willspineventloop,innerbodyfocus,innerbodyblur,innerbodyfocus,", 'Check log'); | ||
}, "Check result"); | ||
w.close(); | ||
done(); | ||
}; | ||
var w = window.open("support/activeelement-after-focusing-different-site-iframe-outer-contentwindow.sub.html"); | ||
</script> |
27 changes: 27 additions & 0 deletions
27
focus/activeelement-after-focusing-different-site-iframe.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>activeElement when focusing different-site iframe</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script> | ||
setup({explicit_done:true}); | ||
window.onmessage = function(e) { | ||
var actual = e.data; | ||
test(function() { | ||
// Handle trailing events separately to get make it easier to see | ||
// if they are the only deviation from the expection. | ||
var endedWith = false; | ||
if (actual.endsWith(",willspineventloop,")) { | ||
endedWith = true; | ||
actual += "innerbodyfocus,innerbodyblur,"; | ||
} | ||
assert_false(endedWith, "Should have gotten innerbodyfocus,innerbodyblur after willspineventloop"); | ||
}, "Check trailing events"); | ||
test(function() { | ||
assert_equals(actual, "outeronload,activeElement:BODY,willfocusiframe,didfocusiframe,activeElement:IFRAME,willbluriframe,didbluriframe,activeElement:BODY,willspineventloop,innerbodyfocus,innerbodyblur,", 'Check log'); | ||
}, "Check result"); | ||
w.close(); | ||
done(); | ||
}; | ||
var w = window.open("support/activeelement-after-focusing-different-site-iframe-outer.sub.html"); | ||
</script> |
27 changes: 27 additions & 0 deletions
27
focus/activeelement-after-focusing-same-site-iframe-contentwindow.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>activeElement when focusing same-site iframe's contentWindow</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script> | ||
setup({explicit_done:true}); | ||
window.onmessage = function(e) { | ||
var actual = e.data; | ||
test(function() { | ||
// Handle trailing events separately to get make it easier to see | ||
// if they are the only deviation from the expection. | ||
var endedWith = false; | ||
if (actual.endsWith(",willspineventloop,")) { | ||
endedWith = true; | ||
actual += "innerbodyfocus,"; | ||
} | ||
assert_false(endedWith, "Should have gotten innerbodyfocus after willspineventloop"); | ||
}, "Check trailing events"); | ||
test(function() { | ||
assert_equals(actual, "outeronload,activeElement:BODY,willfocusiframe,didfocusiframe,activeElement:IFRAME,willbluriframe,didbluriframe,activeElement:IFRAME,willspineventloop,innerbodyfocus,", 'Check log'); | ||
}, "Check result"); | ||
w.close(); | ||
done(); | ||
}; | ||
var w = window.open("support/activeelement-after-focusing-same-site-iframe-outer-contentwindow.html"); | ||
</script> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>activeElement when focusing same-site iframe</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script> | ||
setup({explicit_done:true}); | ||
window.onmessage = function(e) { | ||
var actual = e.data; | ||
test(function() { | ||
// Handle trailing events separately to get make it easier to see | ||
// if they are the only deviation from the expection. | ||
var endedWith = false; | ||
if (actual.endsWith(",willspineventloop,")) { | ||
endedWith = true; | ||
actual += "innerbodyfocus,innerbodyblur,"; | ||
} | ||
assert_false(endedWith, "Should have gotten innerbodyfocus,innerbodyblur after willspineventloop"); | ||
}, "Check trailing events"); | ||
test(function() { | ||
assert_equals(actual, "outeronload,activeElement:BODY,willfocusiframe,didfocusiframe,activeElement:IFRAME,willbluriframe,didbluriframe,activeElement:BODY,willspineventloop,innerbodyfocus,innerbodyblur,", 'Check log'); | ||
}, "Check result"); | ||
w.close(); | ||
done(); | ||
}; | ||
var w = window.open("support/activeelement-after-focusing-same-site-iframe-outer.html"); | ||
</script> |
27 changes: 27 additions & 0 deletions
27
focus/activeelement-after-immediately-focusing-different-site-iframe-contentwindow.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>activeElement when immediately focusing different-site iframe's contentWindow</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script> | ||
setup({explicit_done:true}); | ||
window.onmessage = function(e) { | ||
var actual = e.data; | ||
test(function() { | ||
// Make the difference between Firefox and Chrome visible separately | ||
// from the comparison of the entire log string failing to match. | ||
var endedWith = false; | ||
if (actual.endsWith(",willspineventloop,")) { | ||
endedWith = true; | ||
actual += "innerbodyfocus,"; | ||
} | ||
assert_true(endedWith, "Should not have gotten innerbodyfocus after willspineventloop"); | ||
}, "Check trailing events"); | ||
test(function() { | ||
assert_equals(actual, "outerparser,activeElement:BODY,willfocusiframe,didfocusiframe,activeElement:IFRAME,willbluriframe,didbluriframe,activeElement:IFRAME,willspineventloop,innerbodyfocus,", 'Check log'); | ||
}, "Check result"); | ||
w.close(); | ||
done(); | ||
}; | ||
var w = window.open("support/activeelement-after-immediately-focusing-different-site-iframe-outer-contentwindow.sub.html"); | ||
</script> |
16 changes: 16 additions & 0 deletions
16
focus/activeelement-after-immediately-focusing-different-site-iframe.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>activeElement when immediately focusing different-site iframe</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script> | ||
setup({explicit_done:true}); | ||
window.onmessage = function(e) { | ||
test(function() { | ||
assert_equals(e.data, "outerparser,activeElement:BODY,willfocusiframe,didfocusiframe,activeElement:IFRAME,willbluriframe,didbluriframe,activeElement:BODY,willspineventloop,", 'Check log'); | ||
}, "Check result"); | ||
w.close(); | ||
done(); | ||
}; | ||
var w = window.open("support/activeelement-after-immediately-focusing-different-site-iframe-outer.sub.html"); | ||
</script> |
27 changes: 27 additions & 0 deletions
27
focus/activeelement-after-immediately-focusing-same-site-iframe-contentwindow.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>activeElement when immediately focusing same-site iframe's contentWindow</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script> | ||
setup({explicit_done:true}); | ||
window.onmessage = function(e) { | ||
var actual = e.data; | ||
test(function() { | ||
// Make the difference between Firefox and Chrome visible separately | ||
// from the comparison of the entire log string failing to match. | ||
var endedWith = false; | ||
if (actual.endsWith(",willspineventloop,")) { | ||
endedWith = true; | ||
actual += "innerbodyfocus,"; | ||
} | ||
assert_true(endedWith, "Should not have gotten innerbodyfocus after willspineventloop"); | ||
}, "Check trailing events"); | ||
test(function() { | ||
assert_equals(actual, "outerparse,activeElement:BODY,willfocusiframe,didfocusiframe,activeElement:IFRAME,willbluriframe,didbluriframe,activeElement:IFRAME,willspineventloop,innerbodyfocus,", 'Check log'); | ||
}, "Check result"); | ||
w.close(); | ||
done(); | ||
}; | ||
var w = window.open("support/activeelement-after-immediately-focusing-same-site-iframe-outer-contentwindow.html"); | ||
</script> |
16 changes: 16 additions & 0 deletions
16
focus/activeelement-after-immediately-focusing-same-site-iframe.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>activeElement when immediately focusing same-site iframe</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script> | ||
setup({explicit_done:true}); | ||
window.onmessage = function(e) { | ||
test(function() { | ||
assert_equals(e.data, "outerparse,activeElement:BODY,willfocusiframe,didfocusiframe,activeElement:IFRAME,willbluriframe,didbluriframe,activeElement:BODY,willspineventloop,", 'Check log'); | ||
}, "Check result"); | ||
w.close(); | ||
done(); | ||
}; | ||
var w = window.open("support/activeelement-after-immediately-focusing-same-site-iframe-outer.html"); | ||
</script> |
18 changes: 18 additions & 0 deletions
18
focus/support/activeelement-after-focusing-different-site-iframe-inner-contentwindow.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Inner document</title> | ||
</head> | ||
<body> | ||
<h1>Inner</h1> | ||
<script> | ||
document.body.onfocus = function() { | ||
parent.postMessage("innerbodyfocus,", "*"); | ||
} | ||
document.body.onblur = function() { | ||
parent.postMessage("innerbodyblur,", "*"); | ||
} | ||
</script> | ||
</body> | ||
</html> |
18 changes: 18 additions & 0 deletions
18
focus/support/activeelement-after-focusing-different-site-iframe-inner.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Inner document</title> | ||
</head> | ||
<body> | ||
<h1>Inner</h1> | ||
<script> | ||
document.body.onfocus = function() { | ||
parent.postMessage("innerbodyfocus,", "*"); | ||
} | ||
document.body.onblur = function() { | ||
parent.postMessage("innerbodyblur,", "*"); | ||
} | ||
</script> | ||
</body> | ||
</html> |
29 changes: 29 additions & 0 deletions
29
...s/support/activeelement-after-focusing-different-site-iframe-outer-contentwindow.sub.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<title>activeElement when focusing different-site iframe's contenWindow</title> | ||
<script> | ||
let log = ""; | ||
function getLog() { | ||
return log; | ||
} | ||
window.onmessage = function(e) { | ||
log += e.data; | ||
}; | ||
window.onload = function() { | ||
log += "outeronload,"; | ||
log += "activeElement:" + document.activeElement.tagName + ","; | ||
log += "willfocusiframe,"; | ||
document.getElementsByTagName("iframe")[0].contentWindow.focus(); | ||
log += "didfocusiframe,"; | ||
log += "activeElement:" + document.activeElement.tagName + ","; | ||
log += "willbluriframe,"; | ||
document.getElementsByTagName("iframe")[0].contentWindow.blur(); | ||
log += "didbluriframe,"; | ||
log += "activeElement:" + document.activeElement.tagName + ","; | ||
log += "willspineventloop," | ||
opener.step_timeout(function() { | ||
opener.postMessage(getLog(), "*"); | ||
}, 1500); | ||
} | ||
</script> | ||
<iframe src="http://{{hosts[alt][www]}}:{{ports[http][0]}}/focus/support/activeelement-after-focusing-different-site-iframe-inner-contentwindow.html"></iframe> |
29 changes: 29 additions & 0 deletions
29
focus/support/activeelement-after-focusing-different-site-iframe-outer.sub.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<title>activeElement when focusing different-site iframe</title> | ||
<script> | ||
let log = ""; | ||
function getLog() { | ||
return log; | ||
} | ||
window.onmessage = function(e) { | ||
log += e.data; | ||
}; | ||
window.onload = function() { | ||
log += "outeronload,"; | ||
log += "activeElement:" + document.activeElement.tagName + ","; | ||
log += "willfocusiframe,"; | ||
document.getElementsByTagName("iframe")[0].focus(); | ||
log += "didfocusiframe,"; | ||
log += "activeElement:" + document.activeElement.tagName + ","; | ||
log += "willbluriframe,"; | ||
document.getElementsByTagName("iframe")[0].blur(); | ||
log += "didbluriframe,"; | ||
log += "activeElement:" + document.activeElement.tagName + ","; | ||
log += "willspineventloop," | ||
opener.step_timeout(function() { | ||
opener.postMessage(getLog(), "*"); | ||
}, 1500); | ||
} | ||
</script> | ||
<iframe src="http://{{hosts[alt][www]}}:{{ports[http][0]}}/focus/support/activeelement-after-focusing-different-site-iframe-inner.html"></iframe> |
18 changes: 18 additions & 0 deletions
18
focus/support/activeelement-after-focusing-same-site-iframe-inner-contentwindow.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Inner document</title> | ||
</head> | ||
<body> | ||
<h1>Inner</h1> | ||
<script> | ||
document.body.onfocus = function() { | ||
parent.postMessage("innerbodyfocus,", "*"); | ||
} | ||
document.body.onblur = function() { | ||
parent.postMessage("innerbodyblur,", "*"); | ||
} | ||
</script> | ||
</body> | ||
</html> |
18 changes: 18 additions & 0 deletions
18
focus/support/activeelement-after-focusing-same-site-iframe-inner.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Inner document</title> | ||
</head> | ||
<body> | ||
<h1>Inner</h1> | ||
<script> | ||
document.body.onfocus = function() { | ||
parent.postMessage("innerbodyfocus,", "*"); | ||
} | ||
document.body.onblur = function() { | ||
parent.postMessage("innerbodyblur,", "*"); | ||
} | ||
</script> | ||
</body> | ||
</html> |
29 changes: 29 additions & 0 deletions
29
focus/support/activeelement-after-focusing-same-site-iframe-outer-contentwindow.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<title>activeElement when focusing same-site iframe's contentWindow</title> | ||
<script> | ||
let log = ""; | ||
function getLog() { | ||
return log; | ||
} | ||
window.onmessage = function(e) { | ||
log += e.data; | ||
}; | ||
window.onload = function() { | ||
log += "outeronload,"; | ||
log += "activeElement:" + document.activeElement.tagName + ","; | ||
log += "willfocusiframe,"; | ||
document.getElementsByTagName("iframe")[0].contentWindow.focus(); | ||
log += "didfocusiframe,"; | ||
log += "activeElement:" + document.activeElement.tagName + ","; | ||
log += "willbluriframe,"; | ||
document.getElementsByTagName("iframe")[0].contentWindow.blur(); | ||
log += "didbluriframe,"; | ||
log += "activeElement:" + document.activeElement.tagName + ","; | ||
log += "willspineventloop," | ||
opener.step_timeout(function() { | ||
opener.postMessage(getLog(), "*"); | ||
}, 1500); | ||
} | ||
</script> | ||
<iframe src="activeelement-after-focusing-same-site-iframe-inner-contentwindow.html"></iframe> |
Oops, something went wrong.