summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/browsing-the-web
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/html/browsers/browsing-the-web
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/html/browsers/browsing-the-web')
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/.gitkeep0
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/aborting-a-document-load/.gitkeep0
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/.gitkeep0
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001-1.html11
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001-2.html5
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001.html30
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/MANIFEST16
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/PopStateEvent.html31
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-0.html35
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-1.html6
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-2.html4
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-3.html6
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-4.html6
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name.html13
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin.html41
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin_2.html47
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin_3.html47
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/contains.json6
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/events.html151
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/hashchange_event.html43
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank1.html8
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank2.html8
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/page-with-fragment.html20
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/post_name_on_load.html7
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resume-timer-on-history-back.html145
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-basic.html34
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-cross-origin.html67
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-samedoc.html54
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-cross-origin.html71
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-samedoc.html81
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/popstate_event.html40
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/unset_context_name-1.html7
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/unset_context_name.html7
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/.gitkeep0
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/001-1.html7
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/001-2.html5
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/001-3.html5
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/001.html20
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/002-1.html5
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/002-2.html5
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/002.html23
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/003-1.html7
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/003-2.html9
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/003-3.html4
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/003.html22
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/004-1.html7
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/004-2.html9
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/004-3.html4
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/004.html22
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/005.html16
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/006.html17
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/007.html16
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/008.html17
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/009.html22
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/010.html17
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/011.html21
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/012.html20
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/013.html20
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/014.html21
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/015.html20
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/MANIFEST42
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/blank.html1
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_location-1.html3
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_location-2.html5
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_location-3.html4
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_location.html17
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit-1.html3
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit-2.html6
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit-3.html4
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit.html18
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/click.html4
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment.html20
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment_iframe.html11
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/href.html5
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-query-fragment-components.html28
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-return-value-handling.html36
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_data_url-1.html7
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_data_url.html20
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_same_origin-1.html7
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_same_origin.html20
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-function-parent.html17
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-function-src.html17
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-function.html18
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-src-about-blank.html17
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/support/dummy.html3
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/support/location-set.html8
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/support/set-parent-src.html8
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/read-html/.gitkeep0
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/read-media/.gitkeep0
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/read-media/pageload-image.html30
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/read-media/pageload-video.html30
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/read-multipart-x-mixed-replace/.gitkeep0
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/read-plugin/.gitkeep0
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/read-text/.gitkeep0
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/read-text/load-text-plain.html40
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/read-ua-inline/.gitkeep0
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/read-xml/.gitkeep0
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/.gitkeep0
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/001.html16
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/002.html21
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/003.html25
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/004.html23
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/005.html23
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/006.html34
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/007.html37
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/MANIFEST7
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-frag-percent-encoded.html59
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-anchor-name.html53
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-id-top.html51
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-top.html60
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/.gitkeep0
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/001.html15
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/002.html15
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/003.html15
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/004.html15
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/005.html15
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/MANIFEST33
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/base.html14
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-history-back-1.html5
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-history-back.html31
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-navigation-of-parent-1.html2
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-navigation-of-parent-2.html4
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-navigation-of-parent.html31
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/contains.json6
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload-1.html10
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload-2.html4
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload.html26
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/pagehide-on-history-forward-1.html2
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/pagehide-on-history-forward.html19
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001-1.html10
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001-2.html1
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001.html14
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/002-1.html7
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/002.html20
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/003.html20
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/MANIFEST14
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-001.html9
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-002.html9
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-003.html11
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-004.html11
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-005.html22
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-006.html9
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/next.html2
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/001-1.html23
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/001a.html7
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/001b.html5
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/002-1.html28
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/002a.html7
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/002b.html5
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/003-1.html23
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/003a.html8
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/003b.html5
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/004-1.html25
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/004a.html8
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/004b.html18
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/005-1.html13
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/005a.html8
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/005b.html17
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/001-1.html4
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/001-2.html2
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/001.html25
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/002-1.html4
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/002.html33
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/003-1.html4
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/003.html33
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/004-1.html5
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/004.html28
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/006-1.html20
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/006-2.html5
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/006.html18
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/007-1.html21
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/007-2.html5
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/007.html28
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/008-1.html4
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/008.html16
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/009-1.html4
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/009.html16
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/MANIFEST21
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/manual-001-1.html2
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/manual-001.html5
180 files changed, 3190 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/.gitkeep b/testing/web-platform/tests/html/browsers/browsing-the-web/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/.gitkeep
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/aborting-a-document-load/.gitkeep b/testing/web-platform/tests/html/browsers/browsing-the-web/aborting-a-document-load/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/aborting-a-document-load/.gitkeep
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/.gitkeep b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/.gitkeep
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001-1.html
new file mode 100644
index 000000000..cadcf126f
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001-1.html
@@ -0,0 +1,11 @@
+<!doctype html>
+001-1
+<script>
+addEventListener("pageshow",
+ function(e) {
+ parent.events.push(e);
+ if (parent.events.length == 2) {
+ parent.do_test();
+ }
+ }, false);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001-2.html
new file mode 100644
index 000000000..6387bc89c
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001-2.html
@@ -0,0 +1,5 @@
+<!doctype html>
+001-2
+<script>
+onload = function() {setTimeout(function() {history.go(-1)}, 500)}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001.html
new file mode 100644
index 000000000..26a66304a
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<title>pageshow event from traversal</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe src="001-1.html"></iframe>
+<script>
+var t = async_test();
+var events = [];
+var iframe = document.getElementsByTagName("iframe")[0];
+
+onload = t.step_func(function() {
+ setTimeout(t.step_func(
+ function() {
+ assert_equals(iframe.contentDocument.readyState, "complete")
+ iframe.src = "001-2.html";
+ }), 500);
+ onload = null;
+})
+
+do_test = t.step_func(function() {
+ assert_equals(events.length, 2);
+ events.forEach(function(e, i) {
+ phase = i ? "after" : "before";
+ assert_equals(e.type, "pageshow", "type " + phase + " navigation");
+ assert_equals(e.persisted, i == 0 ? false : true, "persisted " + phase + " navigation");
+ t.done();
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/MANIFEST b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/MANIFEST
new file mode 100644
index 000000000..b3b6014f6
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/MANIFEST
@@ -0,0 +1,16 @@
+support 001-1.html
+support 001-2.html
+001.html
+support browsing_context_name-1.html
+support browsing_context_name-2.html
+support browsing_context_name-3.html
+support browsing_context_name-4.html
+browsing_context_name_cross_origin_2.html
+browsing_context_name_cross_origin_3.html
+browsing_context_name_cross_origin.html
+browsing_context_name.html
+events.html
+hashchange_event.html
+popstate_event.html
+support unset_context_name-1.html
+unset_context_name.html
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/PopStateEvent.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/PopStateEvent.html
new file mode 100644
index 000000000..ace09e574
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/PopStateEvent.html
@@ -0,0 +1,31 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Synthetic popstate events</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function () {
+ var e = document.createEvent('PopStateEvent');
+ var eProto = Object.getPrototypeOf(e);
+ assert_equals(eProto, PopStateEvent.prototype);
+}, 'document.createEvent');
+
+test(function () {
+ assert_false('initPopStateEvent' in PopStateEvent.prototype,
+ 'There should be no PopStateEvent#initPopStateEvent');
+}, 'initPopStateEvent');
+
+test(function () {
+ var state = history.state;
+ var data;
+ window.addEventListener('popstate', function (e) {
+ data = e.state;
+ });
+ window.dispatchEvent(new PopStateEvent('popstate', {
+ 'state': {testdata:true}
+ }));
+ assert_true(data.testdata,'state data was corrupted');
+ assert_equals(history.state, state, "history.state was NOT set by dispatching the event");
+}, 'Dispatching a synthetic PopStateEvent');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-0.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-0.html
new file mode 100644
index 000000000..5cbab71a5
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-0.html
@@ -0,0 +1,35 @@
+<iframe id="test"></iframe>
+<script>
+var opener = window.opener;
+var t = opener.t;
+var f = document.getElementById("test");
+var l = opener.document.getElementById("step_log");
+
+log = function(t) {l.textContent += ("\n" + t)}
+var navigated = false;
+var steps = [
+ () => f.src = "browsing_context_name-1.html",
+ () => {
+ navigated = true;
+ opener.assert_equals(f.contentWindow.name, "test", "Initial load");
+ f.src = "browsing_context_name-2.html"
+ },
+ () => {
+ opener.assert_equals(f.contentWindow.name, "test1");
+ opener.assert_equals(history.length, 2);
+ history.back()
+ },
+ () => {
+ opener.assert_equals(f.contentWindow.name, "test1", "After navigation");
+ t.done();
+ }
+].map((x, i) => t.step_func(() => {log("Step " + (i+1)); x()}));
+
+next = () => steps.shift()();
+
+onload = () => {
+ log("page load");
+ f.onload = () => {log("iframe onload"); next()};
+ setTimeout(next, 0);
+};
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-1.html
new file mode 100644
index 000000000..85748a2eb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-1.html
@@ -0,0 +1,6 @@
+document 1
+<script>
+if (!parent.navigated) {
+ window.name = "test";
+}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-2.html
new file mode 100644
index 000000000..b0c869046
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-2.html
@@ -0,0 +1,4 @@
+document 2
+<script>
+window.name = "test1";
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-3.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-3.html
new file mode 100644
index 000000000..e0c239744
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-3.html
@@ -0,0 +1,6 @@
+document 3
+<script>
+if (!parent.navigated) {
+ window.name = "test3";
+}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-4.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-4.html
new file mode 100644
index 000000000..5d2dfa6bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-4.html
@@ -0,0 +1,6 @@
+document 4
+<script>
+if (!parent.navigated) {
+ window.name = "test4";
+}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name.html
new file mode 100644
index 000000000..60a8acb09
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<title>Retaining window.name on history traversal</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<pre id="step_log"></pre>
+
+<script>
+var t = async_test();
+t.step(() => {
+ win = window.open("browsing_context_name-0.html");
+ t.add_cleanup(() => win.close());
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin.html
new file mode 100644
index 000000000..b04eee66e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin.html
@@ -0,0 +1,41 @@
+<!doctype html>
+<title>Restoring window.name on cross-origin history traversal</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<pre id="step_log"></pre>
+<iframe id="test"></iframe>
+<script>
+
+var t = async_test(undefined, {timeout:10000});
+var f = document.getElementById("test");
+var l = document.getElementById("step_log");
+var navigated = false;
+
+log = function(t) {l.textContent += ("\n" + t)}
+
+var steps = [
+ function() {f.src = "browsing_context_name-1.html"},
+ function() {
+ var navigated = true;
+ assert_equals(f.contentWindow.name, "test", "Initial load");
+ setTimeout(next, 0);
+ },
+ function() {f.src = f.src.replace("http://", "http://www.").replace("browsing_context_name-1", "browsing_context_name-2");},
+ function() {
+ setTimeout(next, 0);
+ },
+ function() {history.back(); setTimeout(next, 500)},
+ function() {
+ assert_equals(f.contentWindow.name, "test", "After navigation");
+ t.done();
+ }
+].map(function(x) {return t.step_func(function() {log("Step " + step); x()})});
+
+var step = 0;
+next = t.step_func(function() {steps[step++]()});
+
+f.onload=next;
+
+onload = setTimeout(next, 0);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin_2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin_2.html
new file mode 100644
index 000000000..1a57e838c
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin_2.html
@@ -0,0 +1,47 @@
+<!doctype html>
+<title>Restoring window.name on cross-origin history traversal</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<pre id="step_log"></pre>
+<iframe id="test"></iframe>
+<script>
+
+var t = async_test(undefined, {timeout:10000});
+var f = document.getElementById("test");
+var l = document.getElementById("step_log");
+var navigated = false;
+
+log = function(t) {l.textContent += ("\n" + t)}
+
+var steps = [
+ function() {f.src = "browsing_context_name-1.html"},
+ function() {
+ var navigated = true;
+ assert_equals(f.contentWindow.name, "test", "Initial load");
+ setTimeout(next, 0);
+ },
+ function() {f.src = "browsing_context_name-3.html"},
+ function() {
+ var navigated = true;
+ assert_equals(f.contentWindow.name, "test3", "Initial load");
+ setTimeout(next, 0);
+ },
+ function() {f.src = f.src.replace("http://", "http://www.").replace("browsing_context_name-3", "browsing_context_name-2");},
+ function() {
+ setTimeout(next, 0);
+ },
+ function() {history.go(-2); setTimeout(next, 500)},
+ function() {
+ assert_equals(f.contentWindow.name, "test3", "After navigation");
+ t.done();
+ }
+].map(function(x) {return t.step_func(function() {log("Step " + step); x()})});
+
+var step = 0;
+next = t.step_func(function() {steps[step++]()});
+
+f.onload=next;
+
+onload = setTimeout(next, 0);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin_3.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin_3.html
new file mode 100644
index 000000000..0f0702732
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin_3.html
@@ -0,0 +1,47 @@
+<!doctype html>
+<title>Restoring window.name on cross-origin history traversal</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<pre id="step_log"></pre>
+<iframe id="test"></iframe>
+<script>
+var t = async_test(undefined, {timeout:10000});
+var f = document.getElementById("test");
+var l = document.getElementById("step_log");
+var navigated = false;
+
+log = function(t) {l.textContent += ("\n" + t)}
+
+var steps = [
+ function() {f.src = "browsing_context_name-1.html"},
+ function() {
+ var navigated = true;
+ assert_equals(f.contentWindow.name, "test", "Initial load");
+ setTimeout(next, 0);
+ },
+ function() {f.src = "browsing_context_name-3.html"},
+ function() {
+ var navigated = true;
+ assert_equals(f.contentWindow.name, "test3", "Initial load");
+ setTimeout(next, 0);
+ },
+ function() {f.src = f.src.replace("http://", "http://www.").replace("browsing_context_name-1", "browsing_context_name-2");},
+ function() {f.src = f.src.replace("http://www.", "http://").replace("browsing_context_name-2", "browsing_context_name-4");},
+ function() {
+ assert_equals(f.contentWindow.name, "test3", "After navigation");
+ history.go(-3); setTimeout(next, 500)
+ },
+ function() {
+ assert_equals(f.contentWindow.name, "test3", "After navigation");
+ t.done();
+ }
+].map(function(x) {return t.step_func(function() {log("Step " + step + " " + f.contentWindow.location); x()})});
+
+var step = 0;
+next = t.step_func(function() {steps[step++]()});
+
+f.onload=next;
+
+onload = setTimeout(next, 0);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/contains.json b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/contains.json
new file mode 100644
index 000000000..90b346668
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/contains.json
@@ -0,0 +1,6 @@
+[
+ {
+ "id": "event-definitions-0",
+ "original_id": "event-definitions-0"
+ }
+] \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/events.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/events.html
new file mode 100644
index 000000000..d5ff83fac
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/events.html
@@ -0,0 +1,151 @@
+<!doctype html>
+<title> PageTransitionEffect Event </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function() {
+ var e = new PageTransitionEvent("pageshow", {persisted:false, cancelable:false, bubbles:false});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pageshow");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+ assert_false(e.persisted, "persisted");
+}, "Constructing pageshow event");
+
+test(function() {
+ var e = new PageTransitionEvent("pagehide", {persisted:false, cancelable:false, bubbles:false});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pagehide");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pagehide event");
+
+test(function() {
+ var e = new PageTransitionEvent("pageshow", {persisted:true});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pageshow");
+ assert_true(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pageshow event, persisted true");
+
+test(function() {
+ var e = new PageTransitionEvent("pagehide", {persisted:true});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pagehide");
+ assert_true(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pagehide event, persisted true");
+
+test(function() {
+ var e = new PageTransitionEvent("pageshow", {});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pageshow");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pageshow event, empty options");
+
+test(function() {
+ var e = new PageTransitionEvent("pagehide", {});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pagehide");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pagehide event, empty options");
+
+test(function() {
+ var e = new PageTransitionEvent("pageshow");
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pageshow");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pageshow event, missing options");
+
+test(function() {
+ var e = new PageTransitionEvent("pagehide");
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pagehide");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pagehide event, missing options");
+
+test(function() {
+ var e = new PageTransitionEvent("pageshow", {persisted:null});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pageshow");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pageshow event, persisted:null");
+
+test(function() {
+ var e = new PageTransitionEvent("pagehide", {persisted:null});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pagehide");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pagehide event, persisted:null");
+
+test(function() {
+ var e = new PageTransitionEvent("pageshow", {persisted:undefined});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pageshow");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pageshow event, persisted:undefined");
+
+test(function() {
+ var e = new PageTransitionEvent("pagehide", {persisted:undefined});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pagehide");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pagehide event, persisted:undefined");
+
+test(function() {
+ var e = new PageTransitionEvent("pageshow", {bubbles:true});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pageshow");
+ assert_false(e.persisted, "persisted");
+ assert_true(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pageshow event, bubbles:true");
+
+test(function() {
+ var e = new PageTransitionEvent("pagehide", {bubbles:true});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pagehide");
+ assert_false(e.persisted, "persisted");
+ assert_true(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pagehide event, bubbles:true");
+
+test(function() {
+ var e = new PageTransitionEvent("pageshow", {cancelable:true});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pageshow");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_true(e.cancelable, "cancelable");
+}, "Constructing pageshow event, cancelable:true");
+
+test(function() {
+ var e = new PageTransitionEvent("pagehide", {cancelable:true});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pagehide");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_true(e.cancelable, "cancelable");
+}, "Constructing pagehide event, cancelable:true");
+
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/hashchange_event.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/hashchange_event.html
new file mode 100644
index 000000000..4b701ad04
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/hashchange_event.html
@@ -0,0 +1,43 @@
+<!doctype html>
+<title>Queue a task to fire hashchange event</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+t = async_test();
+window.onload = t.step_func(function () {
+ if (location.href.toString().indexOf("#") > -1) {
+ location.href = location.href.replace(/#.*$/,'');
+ return;
+ }
+ var root = location.href;
+ var oldURLs = [];
+ var newURLs = [];
+
+ var timer = null;
+
+ location.hash = 'foo';
+ window.onhashchange = t.step_func(function (e) {
+ oldURLs.push(e.oldURL);
+ newURLs.push(e.newURL);
+ if (newURLs.length === 2) {
+ check_result();
+ } else if (timer === null) {
+ timer = setTimeout(function() {check_result()}, 500);
+ }
+ })
+
+ check_result = t.step_func(function() {
+ clearTimeout(timer);
+ try {
+ assert_array_equals([root, root+"#foo"], oldURLs, "e.newURL");
+ assert_array_equals([root+"#foo", root+"#bar"], newURLs, "e.newURL");
+ t.done();
+ } finally {
+ location.hash = "";
+ }
+ });
+
+ location.hash = 'bar';
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank1.html
new file mode 100644
index 000000000..6b4df1ef2
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank1.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<style>
+body {
+ height: 2000px;
+ width: 2000px;
+}
+</style>
+<body> Blank 1 </body> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank2.html
new file mode 100644
index 000000000..def213966
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank2.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<style>
+body {
+ height: 2000px;
+ width: 2000px;
+}
+</style>
+<body> Blank 2 </body>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/page-with-fragment.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/page-with-fragment.html
new file mode 100644
index 000000000..11737661d
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/page-with-fragment.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<style>
+body {
+ height: 2000px;
+ width: 2000px;
+}
+#fragment {
+ position: absolute;
+ top: 800px;
+ background-color: #faa;
+ display: block;
+ height: 100px;
+ width: 100px;
+}
+
+</style>
+<body>
+Page with fragment
+ <a id="fragment" name="fragment" class='box'></a>
+</body> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/post_name_on_load.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/post_name_on_load.html
new file mode 100644
index 000000000..1e9b10d1e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/post_name_on_load.html
@@ -0,0 +1,7 @@
+<!doctype html>
+<script>
+addEventListener('load', _ => {
+ let params = new URLSearchParams(window.location.search);
+ window.opener.postMessage(params.get('name'), '*');
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resume-timer-on-history-back.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resume-timer-on-history-back.html
new file mode 100644
index 000000000..fb7365bd3
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resume-timer-on-history-back.html
@@ -0,0 +1,145 @@
+<!doctype html>
+<title>Verify history.back() on a persisted page resumes timers</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type="text/javascript">
+
+function make_post_back_url(name) {
+ return new URL('resources/post_name_on_load.html?name=' + name,
+ window.location).href;
+}
+
+function wait_for_message(name) {
+ return new Promise(resolve => {
+ addEventListener('message', function onMsg(evt) {
+ if (evt.data !== name) {
+ return;
+ }
+ removeEventListener('message', onMsg);
+ resolve();
+ });
+ });
+}
+
+function with_window_by_name(name) {
+ let win = window.open(make_post_back_url(name));
+ return wait_for_message(name).then(_ => {
+ return win;
+ });
+}
+
+function with_nested_frame(win, url) {
+ return new Promise(resolve => {
+ let frame = win.document.createElement('iframe');
+ frame.addEventListener('load', function onLoad(evt) {
+ removeEventListener('load', onLoad);
+ resolve(frame);
+ });
+ frame.src = url;
+ win.document.body.appendChild(frame);
+ });
+}
+
+function delay(win, delay) {
+ return new Promise(resolve => {
+ win.setTimeout(_ => {
+ resolve(win);
+ }, delay);
+ });
+}
+
+function navigate_by_name(win, name) {
+ win.location = make_post_back_url(name);
+ return wait_for_message(name).then(_ => {
+ return win;
+ });
+}
+
+function go_back(win) {
+ return new Promise(resolve => {
+ win.onpagehide = e => resolve(win);
+ win.history.back();
+ });
+}
+
+let DELAY = 500;
+
+promise_test(t => {
+ // Create a new window so we can navigate it later.
+ return with_window_by_name('foo').then(win => {
+ // Schedule a timer within the new window. Our intent is
+ // to navigate the window before the timer fires.
+ let delayFired = false;
+ let innerDelay = delay(win, DELAY);
+ innerDelay.then(_ => {
+ delayFired = true;
+ });
+
+ return navigate_by_name(win, 'bar').then(_ => {
+ // Since the window has navigated the timer should not
+ // fire. We set a timer on our current test window
+ // to verify the other timer is not received.
+ assert_false(delayFired);
+ return delay(window, DELAY * 2);
+ }).then(_ => {
+ // The navigated window's timer should not have fired.
+ assert_false(delayFired);
+ // Now go back to the document that set the timer.
+ return go_back(win);
+ }).then(_ => {
+ // We wait for one of two conditions here. For browsers
+ // with a bfcache the original suspended timer will fire.
+ // Alternatively, if the browser reloads the page the original
+ // message will be sent again. Wait for either of these
+ // two events.
+ return Promise.race([wait_for_message('foo'), innerDelay]);
+ }).then(_ => {
+ win.close();
+ });
+ });
+}, 'history.back() handles top level page timer correctly');
+
+promise_test(t => {
+ let win;
+ // Create a new window so we can navigate it later.
+ return with_window_by_name('foo').then(w => {
+ win = w;
+
+ // Create a nested frame so we check if navigation and history.back()
+ // properly handle child window state.
+ return with_nested_frame(win, 'about:blank');
+
+ }).then(frame => {
+ // Schedule a timer within the nested frame contained by the new window.
+ // Our intent is to navigate the window before the timer fires.
+ let delayFired = false;
+ let innerDelay = delay(frame.contentWindow, DELAY);
+ innerDelay.then(_ => {
+ delayFired = true;
+ });
+
+ return navigate_by_name(win, 'bar').then(_ => {
+ // Since the window has navigated the timer should not
+ // fire. We set a timer on our current test window
+ // to verify the other timer is not received.
+ assert_false(delayFired);
+ return delay(window, DELAY * 2);
+ }).then(_ => {
+ // The navigated window's timer should not have fired.
+ assert_false(delayFired);
+ // Now go back to the document containing the frame that set the timer.
+ return go_back(win);
+ }).then(_ => {
+ // We wait for one of two conditions here. For browsers
+ // with a bfcache the original suspended timer will fire.
+ // Alternatively, if the browser reloads the page the original
+ // message will be sent again. Wait for either of these
+ // two events.
+ return Promise.race([wait_for_message('foo'), innerDelay]);
+ }).then(_ => {
+ win.close();
+ });
+ });
+}, 'history.back() handles nested iframe timer correctly');
+
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-basic.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-basic.html
new file mode 100644
index 000000000..e47cd9c38
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-basic.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<title>Verify existence and basic read/write function of history.scrollRestoration</title>
+
+<style>
+ body {
+ height: 2000px;
+ width: 2000px;
+ }
+</style>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type="text/javascript">
+ 'use strict';
+
+ test(function() {
+ assert_equals(history.scrollRestoration, 'auto');
+ }, 'Default value is "auto"');
+
+ test(function() {
+ history.scrollRestoration = 'manual';
+ assert_equals(history.scrollRestoration, 'manual', 'should be able to set "manual"');
+ history.scrollRestoration = 'auto';
+ assert_equals(history.scrollRestoration, 'auto', 'should be able to set "auto"');
+ }, 'It is writable');
+
+ test(function() {
+ history.scrollRestoration = 'auto';
+ for (var v of [3.1415, {}, 'bogus']) {
+ history.scrollRestoration = v;
+ assert_equals(history.scrollRestoration, 'auto', `setting to invalid value (${v}) should be ignored`);
+ }
+ }, 'Invalid values are ignored');
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-cross-origin.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-cross-origin.html
new file mode 100644
index 000000000..e3da59e39
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-cross-origin.html
@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<meta name=timeout content=long>
+<title>Precedence of scroll restoration mode over fragment scrolling in cross-origin history traversal</title>
+<style>
+ iframe {
+ height: 300px;
+ width: 300px;
+ }
+</style>
+
+<body>
+ <iframe></iframe>
+</body>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type="text/javascript">
+ 'use strict';
+
+ // The test does the following navigation steps for iframe
+ // 1. load page-with-fragment.html#fragment
+ // 2. load blank1
+ // 3. go back to page-with-fragment.html
+ async_test(function(t) {
+ var iframe = document.querySelector('iframe');
+ var baseURL = location.href.substring(0, location.href.lastIndexOf('/'));
+
+ var steps = [
+ function() {
+ iframe.src = 'resources/page-with-fragment.html#fragment';
+ }, function() {
+ assert_equals(iframe.contentWindow.location.href, baseURL + '/resources/page-with-fragment.html#fragment', 'should be on page-with-fragment page');
+ // wait one animation frame to ensure layout is run and fragment scrolling is complete
+ iframe.contentWindow.requestAnimationFrame(function() {
+ assert_equals(iframe.contentWindow.scrollY, 800, 'should scroll to fragment');
+
+ iframe.contentWindow.history.scrollRestoration = 'manual';
+ assert_equals(iframe.contentWindow.history.scrollRestoration, 'manual');
+ setTimeout(next, 0);
+ });
+ }, function() {
+ // navigate to a new page from a different origin
+ iframe.src = iframe.src.replace("http://", "http://www.").replace("page-with-fragment.html#fragment", "blank1.html");
+ }, function() {
+ // going back causes the iframe to traverse back
+ history.back();
+ }, function() {
+ // coming back from history, scrollRestoration should be set to manual and respected
+ assert_equals(iframe.contentWindow.location.href, baseURL + '/resources/page-with-fragment.html#fragment', 'should be back on page-with-fragment page');
+ iframe.contentWindow.requestAnimationFrame(function() {
+ assert_equals(iframe.contentWindow.history.scrollRestoration, 'manual', 'navigating back should retain scrollRestoration value');
+ assert_equals(iframe.contentWindow.scrollX, 0, 'should not scroll to fragment');
+ assert_equals(iframe.contentWindow.scrollY, 0, 'should not scroll to fragment');
+ t.done();
+ });
+ }
+ ];
+
+ var stepCount = 0;
+ var next = t.step_func(function() {
+ steps[stepCount++]();
+ });
+
+ iframe.onload = next;
+ next();
+ }, 'Manual scroll restoration should take precedent over scrolling to fragment in cross origin navigation');
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-samedoc.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-samedoc.html
new file mode 100644
index 000000000..d837b8f63
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-samedoc.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<style>
+ body {
+ height: 2000px;
+ width: 2000px;
+ }
+
+ #fragment {
+ position: absolute;
+ top: 800px;
+ background-color: #faa;
+ display: block;
+ height: 100px;
+ width: 100px;
+ }
+</style>
+
+<body>
+ <a id="fragment" name="fragment" class='box'></a>
+</body>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type="text/javascript">
+ 'use strict';
+
+ async_test(function(t) {
+ history.scrollRestoration = 'manual';
+ assert_equals(history.scrollRestoration, 'manual');
+
+ location.hash = '#fragment';
+ assert_equals(window.scrollY, 800, 'new navigations should scroll to fragment');
+
+ // create a new entry and reset the scroll before verification
+ history.pushState(null, null, '#done');
+ window.scrollTo(0, 0);
+ assert_equals(window.scrollY, 0, 'should reset scroll before verification');
+
+ setTimeout(function() {
+ // setup verification
+ window.addEventListener('hashchange', t.step_func(function() {
+ assert_equals(location.hash, '#fragment');
+ assert_equals(history.scrollRestoration, 'manual');
+ // navigating back should give precedent to history restoration which is 'manual'
+ assert_equals(window.scrollX, 0, 'should not scroll to fragment');
+ assert_equals(window.scrollY, 0, 'should not scroll to fragment');
+ t.done();
+ }));
+ // kick off verification
+ window.history.back();
+ }, 0);
+
+ }, 'Manual scroll restoration should take precedent over scrolling to fragment in cross doc navigation');
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-cross-origin.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-cross-origin.html
new file mode 100644
index 000000000..87a337b2d
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-cross-origin.html
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<meta name=timeout content=long>
+<title>Correct behaviour of scroll restoration mode is cross origin history traversal</title>
+
+<style>
+ iframe {
+ height: 300px;
+ width: 300px;
+ }
+</style>
+
+<body>
+ <iframe></iframe>
+</body>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type="text/javascript">
+ 'use strict';
+
+ // The test does the following navigation steps for iframe
+ // 1. load blank1
+ // 2. load blank2
+ // 3. go back to blank1
+ async_test(function(t) {
+ var iframe = document.querySelector('iframe');
+ var baseURL = location.href.substring(0, location.href.lastIndexOf('/'));
+
+ var steps = [
+ function() {
+ iframe.src = 'resources/blank1.html';
+ },
+ function() {
+ assert_equals(iframe.contentWindow.location.href, baseURL + '/resources/blank1.html', 'should be on first blank page');
+ iframe.contentWindow.history.scrollRestoration = 'manual';
+ assert_equals(iframe.contentWindow.history.scrollRestoration, 'manual');
+ iframe.contentWindow.scrollTo(500, 500);
+ assert_equals(iframe.contentWindow.scrollX, 500, 'scripted scrolling should take effect');
+ assert_equals(iframe.contentWindow.scrollY, 500, 'scripted scrolling should take effect');
+ setTimeout(next, 0);
+ },
+ function() {
+ // navigate to new page
+ iframe.src = 'resources/blank2.html';
+ },
+ function() {
+ assert_equals(iframe.contentWindow.location.href, baseURL + '/resources/blank2.html', 'should be on second blank page');
+ assert_equals(iframe.contentWindow.history.scrollRestoration, 'auto', 'new page loads should set scrollRestoration to "auto"');
+ setTimeout(next, 0);
+ }, function() {
+ iframe.contentWindow.history.back();
+ }, function() {
+ // coming back scrollRestoration should be restored to 'manual' and respected
+ assert_equals(iframe.contentWindow.location.href, baseURL + '/resources/blank1.html', 'should be back on first blank page');
+ assert_equals(iframe.contentWindow.history.scrollRestoration, 'manual', 'navigating back should retain scrollRestoration value');
+ assert_equals(iframe.contentWindow.scrollX, 0, 'horizontal scroll offset should not be restored');
+ assert_equals(iframe.contentWindow.scrollY, 0, 'vertical scroll offset should not be restored');
+ t.done();
+ }
+ ];
+
+ var stepCount = 0;
+ var next = t.step_func(function() {
+ steps[stepCount++]();
+ });
+
+ iframe.onload = next;
+ next();
+ }, 'Navigating to new page should reset to "auto" and navigating back should restore and respect scroll restoration mode');
+
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-samedoc.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-samedoc.html
new file mode 100644
index 000000000..46d40eedc
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-samedoc.html
@@ -0,0 +1,81 @@
+<!DOCTYPE html>
+<title>Correct behaviour of scroll restoration mode in same document history traversals</title>
+
+<style>
+ body {
+ height: 10000px;
+ width: 10000px;
+ }
+</style>
+
+<body></body>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type="text/javascript">
+ 'use strict';
+
+ async_test(function(t) {
+ history.scrollRestoration = 'auto';
+ window.scrollTo(0, 0);
+
+ // create history entries and then verify the impact of scrollRestoration
+ // when they are popped
+ var entries = {
+ /* For scroll restoration mode 'auto', the spec does not require scroll
+ position to be restored at any particular value. */
+ '#1': {type: 'push', expectedScroll: null, scrollRestoration: 'auto'},
+ '#2': {type: 'replace', expectedScroll: null, scrollRestoration: 'auto'},
+ /* For scroll restoration mode 'manual', the spec requires scroll position
+ not to be restored. So we expect [555,555] which is the latest position
+ before navigation. */
+ '#3': {type: 'push', expectedScroll: [555, 555], scrollRestoration: 'manual'},
+ '#4': {type: 'replace', expectedScroll: [555, 555], scrollRestoration: 'manual'}
+ };
+
+ // setup entries
+ for (var key in entries) {
+ var entry = entries[key],
+ beforeValue = history.scrollRestoration,
+ newValue = entry.scrollRestoration;
+
+ var args = [{key: key}, '', key];
+ if (entry.type == 'push') {
+ history.pushState.apply(history, args);
+ } else {
+ history.pushState(null, '', key);
+ history.replaceState.apply(history, args);
+ }
+ assert_equals(history.scrollRestoration, beforeValue, `history.scrollRestoration value is retained after pushing new state`);
+ history.scrollRestoration = newValue;
+ assert_equals(history.scrollRestoration, newValue, `Setting scrollRestoration to ${newValue} works as expected`);
+ window.scrollBy(50, 100);
+ }
+
+ // setup verification
+ window.addEventListener('hashchange', t.step_func(function() {
+ var key = location.hash,
+ entry = entries[key];
+
+ if (key === '') {
+ t.done();
+ return;
+ }
+ assert_equals(history.state.key, key, `state should have key: ${key}`);
+ assert_equals(history.scrollRestoration, entry.scrollRestoration, 'scrollRestoration is updated correctly');
+ if (entry.expectedScroll) {
+ assert_equals(window.scrollX, entry.expectedScroll[0], `scrollX is correct for ${key}`);
+ assert_equals(window.scrollY, entry.expectedScroll[1], `scrollY is correct for ${key}`);
+ }
+
+ window.history.back();
+ }));
+
+ // reset the scroll and kick off the verification
+ setTimeout(function() {
+ history.pushState(null, null, '#done');
+ window.scrollTo(555, 555);
+ window.history.back();
+ }, 0);
+
+ }, 'history.{push,replace}State retain scroll restoration mode and navigation in the same document respects it');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/popstate_event.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/popstate_event.html
new file mode 100644
index 000000000..7630b9918
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/popstate_event.html
@@ -0,0 +1,40 @@
+<!doctype html>
+<title>Queue a task to fire popstate event</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+t = async_test();
+window.onload = t.step_func(function () {
+ var states = [];
+
+ var timer = null;
+
+ history.pushState("a", "State a", "/a");
+ history.pushState("b", "State b", "/b");
+
+ history.back();
+ window.onpopstate = t.step_func(function (e) {
+ states.push(e.state);
+
+ if (states.length === 2) {
+ check_result();
+ } else if (timer === null) {
+ timer = setTimeout(function() {check_result()}, 500);
+ }
+ })
+
+ check_result = t.step_func(function() {
+ clearTimeout(timer);
+ try {
+ assert_array_equals(states, ["a", null]);
+ t.done();
+ } finally {
+ location.hash = "";
+ }
+ });
+
+ setTimeout(function() {history.back()}, 0);
+
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/unset_context_name-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/unset_context_name-1.html
new file mode 100644
index 000000000..d3d67d0f8
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/unset_context_name-1.html
@@ -0,0 +1,7 @@
+<!doctype html>
+<title>window.name after navigating to a different origin</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+test(function() {assert_equals(window.name, "")})
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/unset_context_name.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/unset_context_name.html
new file mode 100644
index 000000000..6814ed50e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/unset_context_name.html
@@ -0,0 +1,7 @@
+<!doctype html>
+<!-- test must be run in a top level browsing context -->
+<title>window.name after navigating to a different origin</title>
+<script>
+window.name = "test_window";
+location.href = location.href.replace("http://", "http://www.").replace("unset_context_name", "unset_context_name-1");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/.gitkeep b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/.gitkeep
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/001-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/001-1.html
new file mode 100644
index 000000000..df8d884e8
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/001-1.html
@@ -0,0 +1,7 @@
+<!doctype html>
+001-1
+<script>
+addEventListener("unload", function() {
+ location = location.href.replace("http://", "http://www.").replace(/\d{3}-\d\.html/, "001-3.html");
+}, false);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/001-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/001-2.html
new file mode 100644
index 000000000..1cffc59b2
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/001-2.html
@@ -0,0 +1,5 @@
+<!doctype html>
+001-2
+<script>
+parent.postMessage("001-2", "*");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/001-3.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/001-3.html
new file mode 100644
index 000000000..5f1310e07
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/001-3.html
@@ -0,0 +1,5 @@
+<!doctype html>
+001-3.html
+<script>
+parent.postMessage("001-3", "*");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/001.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/001.html
new file mode 100644
index 000000000..7d99f6beb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/001.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>Cross-origin navigation started from unload handler</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe src="001-1.html"></iframe>
+<script>
+var t = async_test();
+onload = t.step_func(function() {
+ var iframe = document.getElementsByTagName("iframe")[0];
+ var new_src = iframe.src.replace(/\d{3}-\d\.html/, "001-2.html");
+ iframe.src = new_src;
+});
+
+onmessage = t.step_func(function(e) {
+ assert_equals(e.data, "001-2");
+ t.done();
+});
+
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/002-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/002-1.html
new file mode 100644
index 000000000..716e182ad
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/002-1.html
@@ -0,0 +1,5 @@
+<!doctype html>
+002-1
+<script>
+parent.postMessage("002-1", "*");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/002-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/002-2.html
new file mode 100644
index 000000000..a29a6bbcd
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/002-2.html
@@ -0,0 +1,5 @@
+<!doctype html>
+002-2
+<script>
+parent.postMessage("002-2", "*");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/002.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/002.html
new file mode 100644
index 000000000..0efc7016f
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/002.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<title>Multiple simultaneous navigations</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe src="about:blank"></iframe>
+<script>
+var t = async_test();
+onload = t.step_func(function() {
+ var iframe = document.getElementsByTagName("iframe")[0];
+
+ setTimeout(t.step_func(function() {
+ iframe.src = "002-1.html?pipe=trickle(d1)";
+ setTimeout(t.step_func(function(){iframe.src = "002-2.html"}), 500);
+ }), 100);
+});
+
+onmessage = t.step_func(function(e) {
+ assert_equals(e.data, "002-2");
+ t.done();
+});
+
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/003-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/003-1.html
new file mode 100644
index 000000000..4d2229eb5
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/003-1.html
@@ -0,0 +1,7 @@
+<!doctype html>
+<script>
+onload = function() {
+ parent.postMessage("003-1", "*");
+ setTimeout(function() {location = "003-2.html";}, 100);
+}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/003-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/003-2.html
new file mode 100644
index 000000000..827a06947
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/003-2.html
@@ -0,0 +1,9 @@
+<!doctype html>
+003-2
+<script>
+onload = function() {
+ parent.postMessage("003-2", "*")
+ setTimeout(function() {history.go(-1)})
+}
+onunload = function() {location = "003-3.html"}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/003-3.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/003-3.html
new file mode 100644
index 000000000..8b26c896f
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/003-3.html
@@ -0,0 +1,4 @@
+<!doctype html>
+<script>
+parent.postMessage("003-3", "*");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/003.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/003.html
new file mode 100644
index 000000000..f43715096
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/003.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<title>Navigation from unload whilst traversing history</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe src="003-1.html"></iframe>
+<script>
+var t = async_test();
+
+var pages = [];
+var iframe = document.getElementsByTagName("iframe")[0];
+
+
+onmessage = t.step_func(function(e) {
+ pages.push(e.data);
+ if(pages.length == 3) {
+ assert_array_equals(pages, ["003-1", "003-2", "003-1"]);
+ t.done();
+ iframe.parentNode.removeChild(iframe);
+ }
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/004-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/004-1.html
new file mode 100644
index 000000000..02f916fd9
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/004-1.html
@@ -0,0 +1,7 @@
+<!doctype html>
+<script>
+onload = function() {
+ parent.postMessage("004-1", "*");
+ setTimeout(function() {location = location.href.replace("http://", "http://www.").replace("004-1.html", "004-2.html");}, 100);
+}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/004-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/004-2.html
new file mode 100644
index 000000000..f2ef83ee1
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/004-2.html
@@ -0,0 +1,9 @@
+<!doctype html>
+003-2
+<script>
+onload = function() {
+ parent.postMessage("004-2", "*")
+ setTimeout(function() {history.go(-1)})
+}
+onunload = function() {location = "004-3.html"}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/004-3.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/004-3.html
new file mode 100644
index 000000000..c98711ae9
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/004-3.html
@@ -0,0 +1,4 @@
+<!doctype html>
+<script>
+parent.postMessage("004-3", "*");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/004.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/004.html
new file mode 100644
index 000000000..dddde4918
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/004.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<title>Navigation from unload whilst traversing cross-origin history</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe src="004-1.html"></iframe>
+<script>
+var t = async_test();
+
+var pages = [];
+var iframe = document.getElementsByTagName("iframe")[0];
+
+
+onmessage = t.step_func(function(e) {
+ pages.push(e.data);
+ if(pages.length == 3) {
+ assert_array_equals(pages, ["004-1", "004-2", "004-1"]);
+ t.done();
+ iframe.parentNode.removeChild(iframe);
+ }
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/005.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/005.html
new file mode 100644
index 000000000..4a044bb25
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/005.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<title>Link with onclick navigation and href navigation </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe id="test" name="test"></iframe>
+<a target="test" onclick="document.getElementById('test').contentWindow.location='click.html'" href="href.html">Test</a>
+<script>
+var t = async_test();
+t.step(function() {document.links[0].click()});
+onmessage = t.step_func(
+ function(e) {
+ assert_equals(e.data, "href");
+ t.done();
+ });
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/006.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/006.html
new file mode 100644
index 000000000..1e7aa2020
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/006.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<title>Link with onclick form submit and href navigation </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe name="test"></iframe>
+<form target="test" action="click.html"></form>
+<a target="test" onclick="document.forms[0].submit()" href="href.html">Test</a>
+<script>
+var t = async_test();
+t.step(function() {document.links[0].click()});
+onmessage = t.step_func(
+ function(e) {
+ assert_equals(e.data, "href");
+ t.done();
+ });
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/007.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/007.html
new file mode 100644
index 000000000..d4bcfc290
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/007.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<title>Link with onclick javascript url and href navigation </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe id="test" name="test"></iframe>
+<a target="test" onclick="document.getElementById('test').contentWindow.location = 'javascript:\'abc<script>parent.postMessage(&quot;click&quot;, &quot;*&quot;)</script>\'';" href="href.html">Test</a>
+<script>
+var t = async_test();
+t.step(function() {document.getElementsByTagName("a")[0].click()});
+onmessage = t.step_func(
+ function(e) {
+ assert_equals(e.data, "href");
+ t.done();
+ });
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/008.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/008.html
new file mode 100644
index 000000000..7d1495a08
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/008.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<title>Link with onclick form submit to javascript url and href navigation </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe id="test" name="test"></iframe>
+<form target="test" action="javascript:'<script>parent.postMessage(&quot;click&quot;, &quot;*&quot;)</script>'"></form>
+<a target="test" onclick="document.forms[0].submit()" href="href.html">Test</a>
+<script>
+var t = async_test();
+t.step(function() {document.getElementsByTagName("a")[0].click()});
+onmessage = t.step_func(
+ function(e) {
+ assert_equals(e.data, "href");
+ t.done();
+ });
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/009.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/009.html
new file mode 100644
index 000000000..0fcd1d37f
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/009.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<title>Link with onclick form submit to javascript url with document.write and href navigation </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe id="test" name="test"></iframe>
+<form target="test" action="javascript:(function() {document.write('<script>parent.postMessage(&quot;write&quot;, &quot;*&quot;)</script>'); return '<script>parent.postMessage(&quot;click&quot;, &quot;*&quot;)</script>'})()"></form>
+<a target="test" onclick="document.forms[0].submit()" href="href.html">Test</a>
+<script>
+var t = async_test();
+var events = [];
+t.step(function() {
+ document.getElementsByTagName("a")[0].click()});
+onmessage = t.step_func(
+ function(e) {
+ events.push(e.data);
+ if (events.length === 2) {
+ assert_array_equals(events, ["write", "href"]);
+ t.done();
+ }
+ });
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/010.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/010.html
new file mode 100644
index 000000000..3917cd16e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/010.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<title>Link with onclick form submit to javascript url with delayed document.write and href navigation </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe id="test" name="test"></iframe>
+<form target="test" action="javascript:(function() {var x = new XMLHttpRequest(); x.open('GET', 'blank.html?pipe=trickle(d2)', false); x.send(); document.write('<script>parent.postMessage(&quot;write&quot;, &quot;*&quot;)</script>'); return '<script>parent.postMessage(&quot;click&quot;, &quot;*&quot;)</script>'})()"></form>
+<a target="test" onclick="document.forms[0].submit()" href="href.html">Test</a>
+<script>
+var t = async_test(undefined, {timeout:4000});
+t.step(function() {document.getElementsByTagName("a")[0].click()});
+onmessage = t.step_func(
+ function(e) {
+ assert_equals(e.data, "href");
+ t.done();
+ });
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/011.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/011.html
new file mode 100644
index 000000000..fe6b8dbc3
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/011.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>Link with onclick navigation to javascript url with document.write and href navigation </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe id="test" name="test"></iframe>
+<a target="test" onclick="javascript:(function() {document.write('<script>parent.postMessage(&quot;write&quot;, &quot;*&quot;)</script>'); return '<script>parent.postMessage(&quot;click&quot;, &quot;*&quot;)</script>'})()" href="href.html">Test</a>
+<script>
+var t = async_test();
+var events = [];
+t.step(function() {
+ document.getElementsByTagName("a")[0].click()});
+onmessage = t.step_func(
+ function(e) {
+ events.push(e.data);
+ if (events.length === 2) {
+ assert_array_equals(events, ["write", "href"]);
+ t.done();
+ }
+ });
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/012.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/012.html
new file mode 100644
index 000000000..be8f2feba
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/012.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>Link with onclick navigation to javascript url with delayed document.write and href navigation </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe id="test" name="test"></iframe>
+<!-- XXX: What is this test trying to do? It's navigating the subframe, but
+ doing a write() to _this_ document, and the "javascript:" in there is
+ completely a red herring: it's a label, not a protocol. There is no
+ javascript url involved here, unlike what the title claims! -->
+<a target="test" onclick="javascript:(function() {var x = new XMLHttpRequest(); x.open('GET', 'blank.html?pipe=trickle(d2)', false); x.send(); document.write('write<script>parent.postMessage(&quot;write&quot;, &quot;*&quot;)</script>'); return '<script>parent.postMessage(&quot;click&quot;, &quot;*&quot;)</script>'})()" href="href.html">Test</a>
+<script>
+var t = async_test(undefined, {timeout:4000});
+t.step(function() {document.getElementsByTagName("a")[0].click()});
+onmessage = t.step_func(
+ function(e) {
+ assert_equals(e.data, "href");
+ t.done();
+ });
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/013.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/013.html
new file mode 100644
index 000000000..69ce7bc61
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/013.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>Link with onclick navigation to javascript url with delayed document.write and href navigation </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe id="test" name="test"></iframe>
+<a target="test" href="javascript:parent.events.push('javascript');">Test</a>
+<script>
+var t = async_test(undefined, {timeout:4000});
+var events = [];
+t.step(function() {
+ document.getElementsByTagName("a")[0].click();
+ events.push('after script');
+});
+onload = t.step_func(function() {
+ // javascript: executions are async.
+ assert_array_equals(events, ['after script', 'javascript']);
+ t.done();
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/014.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/014.html
new file mode 100644
index 000000000..605e18185
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/014.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title> Link with javascript onclick form submission script order </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe id="test" name="test"></iframe>
+<form target="test" action="javascript:parent.events.push('submit');"></form>
+<a target="test" onclick="document.forms[0].submit()">Test</a>
+<script>
+var t = async_test(undefined, {timeout:4000});
+var events = [];
+t.step(function() {
+ document.getElementsByTagName("a")[0].click();
+ events.push('after script');
+});
+onload = t.step_func(function() {
+ // javascript: executions are async.
+ assert_array_equals(events, ['after script', 'submit']);
+ t.done();
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/015.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/015.html
new file mode 100644
index 000000000..eb54622b7
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/015.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title> Link with javascript onclick and href script order </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe id="test" name="test"></iframe>
+<a target="test" onclick="parent.events.push('click');" href="javascript:parent.events.push('href')">Test</a>
+<script>
+var t = async_test(undefined, {timeout:4000});
+var events = [];
+t.step(function() {
+ document.getElementsByTagName("a")[0].click();
+ events.push('after script');
+});
+onload = t.step_func(function() {
+ // javascript: executions are async.
+ assert_array_equals(events, ['click', 'after script', 'href']);
+ t.done();
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/MANIFEST b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/MANIFEST
new file mode 100644
index 000000000..0467aa3b4
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/MANIFEST
@@ -0,0 +1,42 @@
+support 001-1.html
+support 001-2.html
+support 001-3.html
+http 001.html
+support 002-1.html
+support 002-2.html
+002.html
+support 003-1.html
+support 003-2.html
+support 003-3.html
+003.html
+support 004-1.html
+support 004-2.html
+support 004-3.html
+004.html
+005.html
+006.html
+007.html
+008.html
+009.html
+010.html
+011.html
+012.html
+013.html
+014.html
+015.html
+support blank.html
+support child_navigates_parent_location-1.html
+support child_navigates_parent_location-2.html
+support child_navigates_parent_location-3.html
+child_navigates_parent_location.html
+support child_navigates_parent_submit-1.html
+support child_navigates_parent_submit-2.html
+support child_navigates_parent_submit-3.html
+child_navigates_parent_submit.html
+support click.html
+support href.html
+support navigation_unload_data_url-1.html
+navigation_unload_data_url.html
+support navigation_unload_same_origin-1.html
+navigation_unload_same_origin.html
+support slice-and-dice.php
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/blank.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/blank.html
new file mode 100644
index 000000000..c50eddd41
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/blank.html
@@ -0,0 +1 @@
+<!doctype html>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_location-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_location-1.html
new file mode 100644
index 000000000..66afcff22
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_location-1.html
@@ -0,0 +1,3 @@
+<!doctype html>
+<script>parent.postMessage("initial", "*")</script>
+<iframe src="child_navigates_parent_location-2.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_location-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_location-2.html
new file mode 100644
index 000000000..746cf4b0f
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_location-2.html
@@ -0,0 +1,5 @@
+<!doctype html>
+<script>
+parent.parent.postMessage("inner", "*");
+parent.location = "child_navigates_parent_location-3.html"
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_location-3.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_location-3.html
new file mode 100644
index 000000000..bb8ba4e69
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_location-3.html
@@ -0,0 +1,4 @@
+<!doctype html>
+<script>
+parent.postMessage("destination", "*");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_location.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_location.html
new file mode 100644
index 000000000..9111232e2
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_location.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<title>Child document navigating parent via location </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+var events = [];
+onmessage = t.step_func(function(e) {
+ events.push(e.data);
+ if (events.length == 3) {
+ assert_array_equals(events, ["initial", "inner", "destination"]);
+ t.done();
+ }
+});
+</script>
+<iframe src="child_navigates_parent_location-1.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit-1.html
new file mode 100644
index 000000000..cc8616670
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit-1.html
@@ -0,0 +1,3 @@
+<!doctype html>
+<script>parent.postMessage("initial", "*")</script>
+<iframe src="child_navigates_parent_submit-2.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit-2.html
new file mode 100644
index 000000000..34e513de9
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit-2.html
@@ -0,0 +1,6 @@
+<!doctype html>
+<form action="child_navigates_parent_submit-3.html" target="_parent"></form>
+<script>
+parent.parent.postMessage("inner", "*");
+document.forms[0].submit()
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit-3.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit-3.html
new file mode 100644
index 000000000..bb8ba4e69
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit-3.html
@@ -0,0 +1,4 @@
+<!doctype html>
+<script>
+parent.postMessage("destination", "*");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit.html
new file mode 100644
index 000000000..d491a26c1
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<title>Child document navigating parent via submit </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+var events = [];
+onmessage = t.step_func(function(e) {
+ events.push(e.data);
+ if (events.length == 3) {
+ assert_array_equals(events, ["initial", "inner", "destination"]);
+
+ t.done();
+ }
+});
+</script>
+<iframe src="child_navigates_parent_submit-1.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/click.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/click.html
new file mode 100644
index 000000000..8cb03b74d
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/click.html
@@ -0,0 +1,4 @@
+<!doctype html>
+<script>
+parent.postMessage("click", "*");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment.html
new file mode 100644
index 000000000..18a6f84c9
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>Navigating to the same URL with an empty fragment aborts the navigation</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<iframe src="empty_fragment_iframe.html"></iframe>
+<script>
+// If the navigation were not aborted, we would expect multiple load events
+// as the page continually reloads itself.
+async_test(function(t) {
+ var count = 0;
+ var iframe = document.querySelector('iframe');
+ iframe.onload = t.step_func(function() {
+ count++;
+ });
+ window.child_succeeded = t.step_func_done(function() {
+ assert_equals(count, 1);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment_iframe.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment_iframe.html
new file mode 100644
index 000000000..26b28a0d7
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment_iframe.html
@@ -0,0 +1,11 @@
+<script>
+var timeout;
+onload = function() {
+ location.hash = "";
+ timeout = setTimeout(function() { parent.child_succeeded() }, 2000);
+};
+
+onbeforeunload = function() {
+ clearTimeout(timeout);
+}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/href.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/href.html
new file mode 100644
index 000000000..eccadadf4
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/href.html
@@ -0,0 +1,5 @@
+<!doctype html>
+<script>
+parent.postMessage("href", "*");
+</script>
+href
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-query-fragment-components.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-query-fragment-components.html
new file mode 100644
index 000000000..9c18f109c
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-query-fragment-components.html
@@ -0,0 +1,28 @@
+<!doctype html>
+<title> javascript url with query and fragment components </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+var a = null;
+var b = null;
+var c = null;
+</script>
+
+<iframe id="a" src='javascript:"nope" ? "yep" : "what";'></iframe>
+<iframe id="b" src='javascript:"wrong"; // # %0a "ok";'></iframe>
+<iframe id="c" src='javascript:"%252525 ? %252525 # %252525"'></iframe>
+
+<script>
+var t = async_test("iframes with javascript src", {timeout:1000});
+function check(id, expected) {
+ assert_equals(
+ document.getElementById(id).contentDocument.body.textContent,
+ expected);
+}
+onload = t.step_func(function() {
+ check("a", "yep");
+ check("b", "ok");
+ check("c", "%2525 ? %2525 # %2525");
+ t.done();
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-return-value-handling.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-return-value-handling.html
new file mode 100644
index 000000000..621a8cbae
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-return-value-handling.html
@@ -0,0 +1,36 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Test that javascript: evaluation only performs a navigation to the
+ result when the result is a string value.</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<iframe src="javascript:'1'"></iframe>
+<iframe src="javascript:1"></iframe>
+<iframe src="javascript:({ toString: function() { return '1'; } })"></iframe>
+<iframe src="javascript:undefined"></iframe>
+<iframe src="javascript:null"></iframe>
+<iframe src="javascript:true"></iframe>
+<iframe src="javascript:new String('1')"></iframe>
+<script>
+ var t = async_test();
+ onload = t.step_func_done(function() {
+ assert_equals(frames[0].document.documentElement.textContent,
+ "1", "string return should cause navigation");
+ // The rest of the test is disabled for now, until
+ // https://github.com/whatwg/html/issues/1895 gets sorted out
+/*
+ assert_equals(frames[1].document.documentElement.textContent,
+ "", "number return should not cause navigation");
+ assert_equals(frames[2].document.documentElement.textContent,
+ "", "object return should not cause navigation");
+ assert_equals(frames[3].document.documentElement.textContent,
+ "", "undefined return should not cause navigation");
+ assert_equals(frames[4].document.documentElement.textContent,
+ "", "null return should not cause navigation");
+ assert_equals(frames[5].document.documentElement.textContent,
+ "", "null return should not cause navigation");
+ assert_equals(frames[6].document.documentElement.textContent,
+ "", "String object return should not cause navigation");
+*/
+ });
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_data_url-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_data_url-1.html
new file mode 100644
index 000000000..8c412e657
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_data_url-1.html
@@ -0,0 +1,7 @@
+<!doctype html>
+001-1
+<script>
+addEventListener("unload", function() {
+ location = "data:text/html,unload<script>parent.postMessage('fail', '*');<\/script>";
+}, false);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_data_url.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_data_url.html
new file mode 100644
index 000000000..7a8be3e91
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_data_url.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>Same-origin navigation started from unload handler</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe src="navigation_unload_data_url-1.html"></iframe>
+<script>
+var t = async_test();
+onload = t.step_func(function() {
+ var iframe = document.getElementsByTagName("iframe")[0];
+ var new_src = "data:text/html,load<script>parent.postMessage('pass', '*')<\/script>";
+ iframe.src = new_src;
+});
+
+onmessage = t.step_func(function(e) {
+ assert_equals(e.data, "pass");
+ t.done();
+});
+
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_same_origin-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_same_origin-1.html
new file mode 100644
index 000000000..4b52fe3cf
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_same_origin-1.html
@@ -0,0 +1,7 @@
+<!doctype html>
+001-1
+<script>
+addEventListener("unload", function() {
+ location = location.href.replace(/[^\/\.]*\.html/, "001-3.html");
+}, false);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_same_origin.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_same_origin.html
new file mode 100644
index 000000000..b75409cc8
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_same_origin.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>Same-origin navigation started from unload handler</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe src="navigation_unload_same_origin-1.html"></iframe>
+<script>
+var t = async_test();
+onload = t.step_func(function() {
+ var iframe = document.getElementsByTagName("iframe")[0];
+ var new_src = iframe.src.replace(/[^\/\.]*\.html/, "001-2.html");
+ iframe.src = new_src;
+});
+
+onmessage = t.step_func(function(e) {
+ assert_equals(e.data, "001-3");
+ t.done();
+});
+
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-function-parent.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-function-parent.html
new file mode 100644
index 000000000..bd2d9dfdb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-function-parent.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Set location from a parent</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<iframe></iframe>
+<script>
+ onload = function() {
+ var fr = document.querySelector("iframe")
+ fr.contentWindow.location = "support/dummy.html"
+ fr.onload = function() {
+ assert_equals(fr.contentDocument.referrer, document.URL)
+ done()
+ }
+ }
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-function-src.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-function-src.html
new file mode 100644
index 000000000..4a15b3f08
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-function-src.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Set src from a function called from a parent</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<iframe src="support/set-parent-src.html"></iframe>
+<script>
+ onload = function() {
+ var fr = document.querySelector("iframe")
+ fr.contentWindow.go()
+ fr.onload = function() {
+ assert_equals(fr.contentDocument.referrer, document.URL)
+ done()
+ }
+ }
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-function.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-function.html
new file mode 100644
index 000000000..b75062b8d
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-function.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Set location from a function called from a parent</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<iframe src="support/location-set.html"></iframe>
+<script>
+ onload = function() {
+ var fr = document.querySelector("iframe")
+ var url = fr.contentDocument.URL
+ fr.contentWindow.go()
+ fr.onload = function() {
+ assert_equals(fr.contentDocument.referrer, url)
+ done()
+ }
+ }
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-src-about-blank.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-src-about-blank.html
new file mode 100644
index 000000000..dce6ab2f6
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-src-about-blank.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Set the src attribute to about:blank and check referrer</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<iframe></iframe>
+<script>
+ onload = function() {
+ var fr = document.querySelector("iframe")
+ fr.src = "about:blank"
+ fr.onload = function() {
+ assert_equals(fr.contentDocument.referrer, document.URL)
+ done()
+ }
+ }
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/support/dummy.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/support/dummy.html
new file mode 100644
index 000000000..063865709
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/support/dummy.html
@@ -0,0 +1,3 @@
+<!doctype html>
+<meta charset=utf-8>
+<p>Hello. \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/support/location-set.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/support/location-set.html
new file mode 100644
index 000000000..ad733afac
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/support/location-set.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<meta charset=utf-8>
+<script>
+ function go() {
+ location.href = "support/dummy.html"
+ }
+</script>
+<p>Hello. Go. \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/support/set-parent-src.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/support/set-parent-src.html
new file mode 100644
index 000000000..9d45be8c8
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/source/support/set-parent-src.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<meta charset=utf-8>
+<script>
+ function go() {
+ frameElement.src = "support/dummy.html"
+ }
+</script>
+<p>Hello. Go. \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/read-html/.gitkeep b/testing/web-platform/tests/html/browsers/browsing-the-web/read-html/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/read-html/.gitkeep
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/read-media/.gitkeep b/testing/web-platform/tests/html/browsers/browsing-the-web/read-media/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/read-media/.gitkeep
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/read-media/pageload-image.html b/testing/web-platform/tests/html/browsers/browsing-the-web/read-media/pageload-image.html
new file mode 100644
index 000000000..52151b8de
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/read-media/pageload-image.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Media documents: image</title>
+ <link rel="author" title="Michael Ventnor" href="mailto:mventnor@mozilla.com">
+ <link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
+ <link rel="help" href="https://html.spec.whatwg.org/multipage/#read-media">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+
+<script>
+ var t = async_test("The document for a standalone media file should have one child in the body.");
+
+ function frameLoaded() {
+ var testframe = document.getElementById('testframe');
+ var testframeChildren = testframe.contentDocument.body.childNodes;
+ assert_equals(testframeChildren.length, 1, "Body of image document has 1 child");
+ assert_equals(testframeChildren[0].nodeName, "IMG", "Only child of body must be an <img> element");
+ assert_equals(testframeChildren[0].namespaceURI, "http://www.w3.org/1999/xhtml",
+ "Only child of body must be an HTML element");
+ t.done();
+ }
+</script>
+</head>
+<body>
+ <div id="log"></div>
+ <iframe id="testframe" onload="t.step(frameLoaded)"
+ src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9oMFgQGMyFwHucAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAADElEQVQI12P4//8/AAX+Av7czFnnAAAAAElFTkSuQmCC"></iframe>
+</body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/read-media/pageload-video.html b/testing/web-platform/tests/html/browsers/browsing-the-web/read-media/pageload-video.html
new file mode 100644
index 000000000..13bc5db4a
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/read-media/pageload-video.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Media documents: video</title>
+ <link rel="author" title="Michael Ventnor" href="mailto:mventnor@mozilla.com">
+ <link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
+ <link rel="help" href="https://html.spec.whatwg.org/multipage/#read-media">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+
+<script>
+ var t = async_test("The document for a standalone media file should have one child in the body.");
+
+ function frameLoaded() {
+ var testframe = document.getElementById('testframe');
+ var testframeChildren = testframe.contentDocument.body.childNodes;
+ assert_equals(testframeChildren.length, 1, "Body of image document has 1 child");
+ assert_equals(testframeChildren[0].nodeName, "VIDEO", "Only child of body must be an <video> element");
+ assert_equals(testframeChildren[0].namespaceURI, "http://www.w3.org/1999/xhtml",
+ "Only child of body must be an HTML element");
+ t.done();
+ }
+</script>
+</head>
+<body>
+ <div id="log"></div>
+ <iframe id="testframe" onload="t.step(frameLoaded)"
+ src="data:video/webm,"></iframe>
+</body>
+</html>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/read-multipart-x-mixed-replace/.gitkeep b/testing/web-platform/tests/html/browsers/browsing-the-web/read-multipart-x-mixed-replace/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/read-multipart-x-mixed-replace/.gitkeep
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/read-plugin/.gitkeep b/testing/web-platform/tests/html/browsers/browsing-the-web/read-plugin/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/read-plugin/.gitkeep
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/read-text/.gitkeep b/testing/web-platform/tests/html/browsers/browsing-the-web/read-text/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/read-text/.gitkeep
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/read-text/load-text-plain.html b/testing/web-platform/tests/html/browsers/browsing-the-web/read-text/load-text-plain.html
new file mode 100644
index 000000000..bd4fd7859
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/read-text/load-text-plain.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<title>Page load processing model for text files</title>
+<link rel="author" title="Ms2ger" href="ms2ger@gmail.com">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#read-text">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test("Checking document metadata for text file");
+var tD = async_test("Checking DOM for text file");
+var tC = async_test("Checking contents for text file");
+var iframe = document.body.appendChild(document.createElement("iframe"));
+iframe.onload = function(e) {
+ var doc = iframe.contentDocument;
+ t.step(function() {
+ assert_equals(doc.compatMode, "BackCompat");
+ assert_equals(doc.contentType, "text/plain");
+ assert_equals(doc.doctype, null);
+ t.done();
+ })
+ tD.step(function() {
+ assert_equals(doc.childNodes.length, 1, "Document should have 1 child")
+ assert_equals(doc.documentElement.tagName, "HTML");
+ assert_equals(doc.documentElement.childNodes.length, 2,
+ "Root element should have 2 children")
+ assert_equals(doc.documentElement.firstChild.tagName, "HEAD");
+ assert_equals(doc.documentElement.lastChild.tagName, "BODY");
+ assert_equals(doc.documentElement.lastChild.childNodes.length, 1,
+ "Body element should have 1 child")
+ assert_equals(doc.documentElement.lastChild.firstChild.tagName, "PRE");
+ tD.done();
+ })
+ tC.step(function() {
+ assert_equals(doc.documentElement.lastChild.firstChild.firstChild.data,
+ "This is a sample text/plain document.\n\nThis is not an HTML document.\n\n");
+ tC.done();
+ })
+};
+iframe.src = "../../../../common/text-plain.txt";
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/read-ua-inline/.gitkeep b/testing/web-platform/tests/html/browsers/browsing-the-web/read-ua-inline/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/read-ua-inline/.gitkeep
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/read-xml/.gitkeep b/testing/web-platform/tests/html/browsers/browsing-the-web/read-xml/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/read-xml/.gitkeep
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/.gitkeep b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/.gitkeep
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/001.html b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/001.html
new file mode 100644
index 000000000..32599bbc5
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/001.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<!-- this tests the spec as it hopefully will be once bug https://www.w3.org/Bugs/Public/show_bug.cgi?id=17155 is fixed -->
+<title>Fragment Navigation: Updating document address</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function() {
+ assert_equals(location.hash, "", "Page must be loaded with no hash")
+ var original_location = location.href;
+ location.hash = "test";
+ assert_equals(location.hash, "#test");
+ assert_equals(location.href, original_location + "#test");
+ location.hash = ""
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/002.html b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/002.html
new file mode 100644
index 000000000..92bfd6341
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/002.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<!-- this tests the spec as it hopefully will be once bug https://www.w3.org/Bugs/Public/show_bug.cgi?id=17155 is fixed -->
+<title>Fragment Navigation: Updating document address twice</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function() {
+ assert_equals(location.hash, "", "Page must be loaded with no hash")
+ var original_location = location.href;
+ location.hash = "test";
+ assert_equals(location.hash, "#test");
+ assert_equals(location.href, original_location + "#test");
+
+ location.hash = "test1";
+ assert_equals(location.hash, "#test1");
+ assert_equals(location.href, original_location + "#test1");
+
+ location.hash = "";
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/003.html b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/003.html
new file mode 100644
index 000000000..200a6dc34
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/003.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<!-- this tests the spec as it hopefully will be once bug https://www.w3.org/Bugs/Public/show_bug.cgi?id=17155 is fixed -->
+<title>Fragment Navigation: Updating scroll position</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<div id="log"></div>
+<div id="test">scroll 1</div>
+<div style="height:10000px">Filler</div>
+<div id="test1">scroll 2</div>
+<script>
+test(function() {
+ assert_equals(document.body.scrollTop, 0);
+ location.hash = "test";
+
+ var scroll1 = document.body.scrollTop;
+ assert_true(scroll1 > 0);
+
+ location.hash = "test1";
+ var scroll2 = document.body.scrollTop;
+ assert_true(scroll2 > scroll1);
+
+ location.hash = ""
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/004.html b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/004.html
new file mode 100644
index 000000000..950172d7b
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/004.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<!-- this tests the spec as it hopefully will be once bug https://www.w3.org/Bugs/Public/show_bug.cgi?id=17155 is fixed -->
+<title>Fragment Navigation: hashchange event</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<div id="log"></div>
+<script>
+var t = async_test();
+t.step(function() {
+ assert_equals(location.hash, "", "Page must be loaded with no hash");
+ location.hash = "test";
+
+ addEventListener("hashchange",
+ t.step_func(function(e) {
+ assert_equals(e.target, window);
+ assert_equals(e.type, "hashchange");
+ assert_true(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+ t.done();
+ }), true)
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/005.html b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/005.html
new file mode 100644
index 000000000..f0761a64f
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/005.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<!-- this tests the spec as it hopefully will be once bug https://www.w3.org/Bugs/Public/show_bug.cgi?id=17155 is fixed -->
+<title>Fragment Navigation: hashchange event</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<div id="log"></div>
+<script>
+var t = async_test();
+t.step(function() {
+ var original_url = location.href;
+ assert_equals(location.hash, "", "Page must be loaded with no hash");
+ location.hash = "test";
+
+ addEventListener("hashchange",
+ t.step_func(function(e) {
+ assert_equals(e.oldURL, original_url, "oldURL property");
+ assert_equals(e.newURL, location.href, "newURL property");
+ location.hash = "";
+ t.done();
+ }), true);
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/006.html b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/006.html
new file mode 100644
index 000000000..a65b9eb4a
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/006.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<!-- this tests the spec as it hopefully will be once bug https://www.w3.org/Bugs/Public/show_bug.cgi?id=17155 is fixed -->
+<title>Fragment Navigation: hashchange event multiple changes old/newURL</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<div id="log"></div>
+<script>
+var t = async_test();
+t.step(function() {
+ var original_url = location.href;
+ assert_equals(location.hash, "", "Page must be loaded with no hash");
+ location.hash = "test";
+
+ var count = 0;
+ var mid_url = location.href;
+
+ addEventListener("hashchange",
+ t.step_func(function(e) {
+ if (count === 0) {
+ assert_equals(e.oldURL, original_url, "oldURL property first update");
+ assert_equals(e.newURL, mid_url, "newURL property first update");
+ count = 1;
+ } else if (count === 1) {
+ assert_equals(e.oldURL, mid_url, "oldURL property second update");
+ assert_equals(e.newURL, location.href, "newURL property second update");
+ location.hash = "";
+ t.done();
+ }
+ }), true);
+
+ location.hash = "test1";
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/007.html b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/007.html
new file mode 100644
index 000000000..0b6fe813b
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/007.html
@@ -0,0 +1,37 @@
+<!doctype html>
+<!-- this tests the spec as it hopefully will be once bug https://www.w3.org/Bugs/Public/show_bug.cgi?id=17155 is fixed -->
+<title>Fragment Navigation: hashchange event multiple changes old/newURL</title>
+<meta name=timeout content=long>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<div id="log"></div>
+<script>
+var t = async_test();
+t.step(function() {
+ var original_url = location.href;
+ assert_equals(location.hash, "", "Page must be loaded with no hash");
+
+ var count = 0;
+
+ location.hash = "test";
+
+ hashes = [];
+
+ addEventListener("hashchange",
+ t.step_func(function(e) {
+ if (count < 100) {
+ location.hash = "test" + count++;
+ hashes.push(location.hash);
+ } else if (count === 100) {
+ expected = [];
+ for (var i=0; i<100; i++) {
+ expected.push("#test" + i);
+ }
+ assert_array_equals(hashes, expected);
+ location.hash = "";
+ t.done();
+ }
+ }), true);
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/MANIFEST b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/MANIFEST
new file mode 100644
index 000000000..eaa8e6d61
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/MANIFEST
@@ -0,0 +1,7 @@
+001.html
+002.html
+003.html
+004.html
+005.html
+006.html
+007.html
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-frag-percent-encoded.html b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-frag-percent-encoded.html
new file mode 100644
index 000000000..3196d8be8
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-frag-percent-encoded.html
@@ -0,0 +1,59 @@
+<!doctype html>
+<title>Fragment Navigation: fragment id should be percent-decoded</title>
+<meta name=timeout content=long>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<div></div>
+<div id="has two spaces" style="position:absolute; top:200px;"></div>
+<div id="escape%20collision" style="position:absolute; top:300px;"></div>
+<div id="escape collision" style="position:absolute; top:400px;"></div>
+<div id="do%20not%20go%20here" style="position:absolute; top:400px;"></div>
+<div style="height:200em;"></div>
+<script>
+var steps = [{
+ fragid:'has%20two%20spaces',
+ handler: function(){
+ assert_equals( scrollPosition(), 200 );
+ }
+ },{
+ fragid:'escape%20collision',
+ handler: function(){
+ assert_equals( scrollPosition(), 400 );
+ }
+ },{
+ fragid:'do%20not%20go%20here',
+ handler: function(){
+ // don't move
+ assert_equals( scrollPosition(), 400 );
+ }
+ }];
+
+function scrollPosition(){
+ return document.documentElement.scrollTop || document.body.scrollTop;
+}
+
+function runNextStep(){
+ if( steps.length > 0 ) {
+ var step = steps.shift();
+ var listener = t.step_func( function(){
+ step.handler();
+ runNextStep();
+ });
+ scrollToFragmentThenDo( step.fragid, listener );
+ } else {
+ t.done();
+ }
+}
+
+function scrollToFragmentThenDo( fragid, then ){
+ location.hash = fragid;
+ setTimeout( then, 1 );
+}
+
+var t = async_test();
+t.step( function(){
+ assert_equals(location.hash, "", "Page must be loaded with no hash");
+ runNextStep();
+})
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-anchor-name.html b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-anchor-name.html
new file mode 100644
index 000000000..43dbaf9e2
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-anchor-name.html
@@ -0,0 +1,53 @@
+<!doctype html>
+<title>Fragment Navigation: scroll to anchor name is lower priority than equal id</title>
+<meta name=timeout content=long>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<div></div>
+<a name="anchor1" style="position:absolute; top:200px;"></a>
+<div id="id-equals-anchor" style="position:absolute; top:300px;"></div>
+<a name="id-equals-anchor" style="position:absolute; top:400px;"></a>
+<div style="height:200em;"></div>
+<script>
+var steps = [{
+ fragid:'anchor1',
+ handler: function(){
+ assert_equals( scrollPosition(), 200 );
+ }
+ },{
+ fragid:'id-equals-anchor',
+ handler: function(){
+ // id still takes precedence over anchor name
+ assert_equals( scrollPosition(), 300 );
+ }
+ }];
+
+function scrollPosition(){
+ return document.documentElement.scrollTop || document.body.scrollTop;
+}
+
+function runNextStep(){
+ if( steps.length > 0 ) {
+ var step = steps.shift();
+ var listener = t.step_func( function(){
+ step.handler();
+ runNextStep();
+ });
+ scrollToFragmentThenDo( step.fragid, listener );
+ } else {
+ t.done();
+ }
+}
+
+function scrollToFragmentThenDo( fragid, then ){
+ location.hash = fragid;
+ setTimeout( then, 1 );
+}
+
+var t = async_test();
+t.step( function(){
+ assert_equals(location.hash, "", "Page must be loaded with no hash");
+ runNextStep();
+})
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-id-top.html b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-id-top.html
new file mode 100644
index 000000000..601d40a2a
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-id-top.html
@@ -0,0 +1,51 @@
+<!doctype html>
+<title>Fragment Navigation: TOP is a valid element id, which overrides navigating to top of the document</title>
+<meta name=timeout content=long>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<div></div>
+<div id="Top" style="position:absolute; top:200px;"></div>
+<div style="height:200em; position:relative;"></div>
+<script>
+var steps = [{
+ fragid:'Top',
+ handler: function(){
+ assert_equals( scrollPosition(), 200 );
+ }
+ },{
+ // scroling to top should work when fragid differs from id by case.
+ fragid:'top',
+ handler: function(){
+ assert_equals( scrollPosition(), 0 );
+ }
+ }];
+
+function scrollPosition(){
+ return document.documentElement.scrollTop || document.body.scrollTop;
+}
+
+function runNextStep(){
+ if( steps.length > 0 ) {
+ var step = steps.shift();
+ var listener = t.step_func( function(){
+ step.handler();
+ runNextStep();
+ });
+ scrollToFragmentThenDo( step.fragid, listener );
+ } else {
+ t.done();
+ }
+}
+
+function scrollToFragmentThenDo( fragid, then ){
+ location.hash = fragid;
+ setTimeout( then, 1 );
+}
+
+var t = async_test();
+t.step( function(){
+ assert_equals(location.hash, "", "Page must be loaded with no hash");
+ runNextStep();
+})
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-top.html b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-top.html
new file mode 100644
index 000000000..3265a71bf
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-top.html
@@ -0,0 +1,60 @@
+<!doctype html>
+<title>Fragment Navigation: When fragid is TOP scroll to the top of the document</title>
+<meta name=timeout content=long>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<div></div>
+<div id="not-the-top"></div>
+<div style="height:200em"></div>
+<script>
+var steps = [{
+ fragid:'not-the-top',
+ handler: function(){
+ assert_not_equals( scrollPosition(), 0 );
+ }
+ },{
+ fragid:'top',
+ handler: function(){
+ assert_equals( scrollPosition(), 0 );
+ }
+ },{
+ fragid:'not-the-top',
+ handler: function(){
+ assert_not_equals( scrollPosition(), 0 );
+ }
+ },{
+ fragid:'TOP',
+ handler: function(){
+ assert_equals( scrollPosition(), 0 );
+ }
+ }];
+
+function scrollPosition(){
+ return document.documentElement.scrollTop || document.body.scrollTop;
+}
+
+function runNextStep(){
+ if( steps.length > 0 ) {
+ var step = steps.shift();
+ var listener = t.step_func( function(){
+ step.handler();
+ runNextStep();
+ });
+ scrollToFragmentThenDo( step.fragid, listener );
+ } else {
+ t.done();
+ }
+}
+
+function scrollToFragmentThenDo( fragid, then ){
+ location.hash = fragid;
+ setTimeout( then, 1 );
+}
+
+var t = async_test();
+t.step( function(){
+ assert_equals(location.hash, "", "Page must be loaded with no hash");
+ runNextStep();
+})
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/.gitkeep b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/.gitkeep
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/001.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/001.html
new file mode 100644
index 000000000..1ef88d3cc
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/001.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>document.open in unload</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+var win;
+
+t.step(function() {
+ win = window.open("support/001-1.html");
+});
+
+add_completion_callback(function() {win.close()});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/002.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/002.html
new file mode 100644
index 000000000..a4e0b243e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/002.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>document.open in unload</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+var win;
+
+t.step(function() {
+ win = window.open("support/002-1.html");
+});
+
+add_completion_callback(function() {win.close()});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/003.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/003.html
new file mode 100644
index 000000000..d0a19e0dd
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/003.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>document.open in beforeunload with link</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+var win;
+
+t.step(function() {
+ win = window.open("support/003-1.html");
+});
+
+add_completion_callback(function() {win.close()});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/004.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/004.html
new file mode 100644
index 000000000..fca926f65
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/004.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>document.open in beforeunload with button</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+var win;
+
+t.step(function() {
+ win = window.open("support/004-1.html");
+});
+
+add_completion_callback(function() {win.close()});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/005.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/005.html
new file mode 100644
index 000000000..c215fb88e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/005.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>document.open in pagehide in iframe</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+var win;
+
+t.step(function() {
+ win = window.open("support/005-1.html");
+});
+
+add_completion_callback(function() {win.close()});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/MANIFEST b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/MANIFEST
new file mode 100644
index 000000000..f77806795
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/MANIFEST
@@ -0,0 +1,33 @@
+support 001-1.html
+support 001a.html
+support 001b.html
+001.html
+support 002-1.html
+support 002a.html
+support 002b.html
+002.html
+support 003-1.html
+support 003a.html
+support 003b.html
+003.html
+support 004-1.html
+support 004a.html
+support 004b.html
+004.html
+support 005-1.html
+support 005a.html
+support 005b.html
+005.html
+base.html
+support beforeunload-on-history-back-1.html
+beforeunload-on-history-back.html
+support beforeunload-on-navigation-of-parent-1.html
+support beforeunload-on-navigation-of-parent-2.html
+beforeunload-on-navigation-of-parent.html
+support navigation-within-beforeunload-1.html
+support navigation-within-beforeunload-2.html
+navigation-within-beforeunload.html
+support pagehide-on-history-forward-1.html
+pagehide-on-history-forward.html
+dir prompt
+dir unload
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/base.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/base.html
new file mode 100644
index 000000000..70c07cba4
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/base.html
@@ -0,0 +1,14 @@
+<!doctype html>
+Base
+<script>
+onpagehide = function() {
+ if(top.base_hide) {
+ top.base_hide();
+ }
+}
+onpageshow = function() {
+if (top.base_show) {
+ top.base_show();
+}
+}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-history-back-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-history-back-1.html
new file mode 100644
index 000000000..4403cfa8e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-history-back-1.html
@@ -0,0 +1,5 @@
+<!doctype html>
+001-1
+<script>
+addEventListener("beforeunload", function() {top.t.step(function() {top.beforeunload_fired = true})}, false);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-history-back.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-history-back.html
new file mode 100644
index 000000000..5b0415c42
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-history-back.html
@@ -0,0 +1,31 @@
+<!doctype html>
+<title>beforeunload event fires on history navigation back</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+beforeunload_fired = false;
+var t = async_test();
+
+var base_count = 0;
+
+onload = function() {setTimeout(t.step_func(function() {
+ var iframe = document.getElementsByTagName("iframe")[0]
+ iframe.onload = t.step_func(function() {
+ iframe.onload = null;
+ history.go(-1);
+ });
+
+ iframe.src = "beforeunload-on-history-back-1.html";
+}), 100)};
+
+base_show = t.step_func(function() {
+ base_count++;
+ if (base_count > 1) {
+ assert_true(beforeunload_fired);
+ t.done();
+ }
+});
+
+</script>
+<iframe src="base.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-navigation-of-parent-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-navigation-of-parent-1.html
new file mode 100644
index 000000000..4f239dad1
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-navigation-of-parent-1.html
@@ -0,0 +1,2 @@
+<!doctype html>
+<iframe src="beforeunload-on-navigation-of-parent-2.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-navigation-of-parent-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-navigation-of-parent-2.html
new file mode 100644
index 000000000..a34b182e7
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-navigation-of-parent-2.html
@@ -0,0 +1,4 @@
+<!doctype html>
+<script>
+addEventListener("beforeunload", function() {parent.parent.beforeunload_fired=true}, false)
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-navigation-of-parent.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-navigation-of-parent.html
new file mode 100644
index 000000000..96d49567f
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-on-navigation-of-parent.html
@@ -0,0 +1,31 @@
+<!doctype html>
+<title>beforeunload in iframe on navigation of parent</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+beforeunload_fired = false;
+var t = async_test();
+
+var base_count = 0;
+
+onload = function() {setTimeout(t.step_func(function() {
+ var iframe = document.getElementsByTagName("iframe")[0]
+ iframe.onload = t.step_func(function() {
+ iframe.onload = null;
+ history.go(-1);
+ });
+
+ iframe.src = "beforeunload-on-navigation-of-parent-1.html";
+}), 100)};
+
+base_show = t.step_func(function() {
+ base_count++;
+ if (base_count > 1) {
+ assert_true(beforeunload_fired);
+ t.done();
+ }
+});
+
+</script>
+<iframe src="base.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/contains.json b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/contains.json
new file mode 100644
index 000000000..4ebca09bf
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/contains.json
@@ -0,0 +1,6 @@
+[
+ {
+ "id": "event-definition",
+ "original_id": "event-definition"
+ }
+] \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload-1.html
new file mode 100644
index 000000000..b96234fba
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload-1.html
@@ -0,0 +1,10 @@
+<!doctype html>
+004-1
+<script>
+addEventListener("beforeunload",
+function() {
+if (top.counter++ < 999) {
+ location = "navigation-within-beforeunload-2.html?" + top.counter;
+}
+}, false);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload-2.html
new file mode 100644
index 000000000..2dceaa6d6
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload-2.html
@@ -0,0 +1,4 @@
+<!doctype html>
+<script>
+document.write(location)
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload.html
new file mode 100644
index 000000000..d7131b00d
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<title>Triggering navigation from within beforeunload event</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+beforeunload_fired = false;
+var t = async_test();
+
+var base_count = 0;
+var counter = 0;
+
+onload = function() {setTimeout(function() {
+ var iframe = document.getElementsByTagName("iframe")[0]
+
+ iframe.onload = function() {
+ setTimeout(function() {iframe.contentWindow.location="navigation-within-beforeunload-2.html";}, 100);
+ iframe.onload = t.step_func(function() {assert_equals(counter, 1000); t.done()});
+ };
+
+ iframe.src = "navigation-within-beforeunload-1.html?" + Math.random();
+
+}, 100)};
+
+</script>
+<iframe src="base.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/pagehide-on-history-forward-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/pagehide-on-history-forward-1.html
new file mode 100644
index 000000000..a60c20ed8
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/pagehide-on-history-forward-1.html
@@ -0,0 +1,2 @@
+<!doctype html>
+filler text
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/pagehide-on-history-forward.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/pagehide-on-history-forward.html
new file mode 100644
index 000000000..5e64b5ec6
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/pagehide-on-history-forward.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>pagehide event fires on history navigation forward</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+
+onload = function() {setTimeout(t.step_func(function() {
+ var iframe = document.getElementsByTagName("iframe")[0]
+
+ iframe.src = "pagehide-on-history-forward-1.html";
+}), 100)};
+
+base_hide = t.step_func(function() {
+ t.done()
+});
+</script>
+<iframe src="base.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001-1.html
new file mode 100644
index 000000000..b68afc49e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001-1.html
@@ -0,0 +1,10 @@
+<script>
+addEventListener("beforeunload",
+function() {
+ parent.events.push("beforeunload");
+}, false);
+parent.events.push("before src change");
+
+location.href = "001-2.html&pipe=trickle(d2)";
+parent.events.push("after src change");
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001-2.html
new file mode 100644
index 000000000..9da0f9395
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001-2.html
@@ -0,0 +1 @@
+001-2
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001.html
new file mode 100644
index 000000000..109dcc139
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<title>beforeunload event order</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+events = [];
+onload = t.step_func(function() {
+ assert_array_equals(events, ["before src change", "beforeunload", "after src change"]);
+ t.done();
+})
+</script>
+<iframe src="001-1.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/002-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/002-1.html
new file mode 100644
index 000000000..c5f57375d
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/002-1.html
@@ -0,0 +1,7 @@
+<script>
+addEventListsner("beforeunload", parent.t.step_func(
+function(e) {
+ parent.do_test(e);
+}, false);
+location.href = "001-2.html&pipe=trickle(d2)";
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/002.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/002.html
new file mode 100644
index 000000000..d8f4fc60a
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/002.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>beforeunload event properties</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+
+function do_test(e) {
+ assert_equals(e.type, "beforeunload");
+ assert_false(e.bubbles, "bubbles");
+ assert_true(e.cancelable, "bubbles");
+ assert_equals(e.returnValue, "");
+}
+
+onload = t.step_func(function() {
+ t.done();
+})
+</script>
+<iframe src="001-1.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/003.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/003.html
new file mode 100644
index 000000000..5683f1b12
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/003.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>beforeunload event in child frame for parent navigation</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+
+function do_test(e) {
+ assert_equals(e.type, "beforeunload");
+ assert_false(e.bubbles, "bubbles");
+ assert_true(e.cancelable, "bubbles");
+ assert_equals(e.returnValue, "");
+}
+
+onload = t.step_func(function() {
+ t.done();
+})
+</script>
+<iframe src="001-1.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/MANIFEST b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/MANIFEST
new file mode 100644
index 000000000..8d93279a4
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/MANIFEST
@@ -0,0 +1,14 @@
+support 001-1.html
+support 001-2.html
+001.html
+support 002-1.html
+002.html
+003.html
+manual manual-001.html
+manual manual-002.html
+manual manual-003.html
+manual manual-004.html
+manual manual-005.html
+manual manual-006.html
+support next.html
+support slice-and-dice.php
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-001.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-001.html
new file mode 100644
index 000000000..3b7ef74b7
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-001.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<title>Prompt when beforeunload is canceled</title>
+<script>
+addEventListener("beforeunload",
+function(e) {e.preventDefault()},
+false);
+</script>
+<p>When clicking the link below, you should get a prompt asking if you want to unload the document</p>
+<a href="next.html">Click here</a>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-002.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-002.html
new file mode 100644
index 000000000..7be8a3301
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-002.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<title>Prompt when beforeunload has returnValue set</title>
+<script>
+addEventListener("beforeunload",
+function(e) {e.returnValue = "PASS if you see this"},
+false);
+</script>
+<p>When clicking the link below, you should get a prompt asking if you want to unload the document</p>
+<a href="next.html">Click here</a>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-003.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-003.html
new file mode 100644
index 000000000..ff72b6705
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-003.html
@@ -0,0 +1,11 @@
+<!doctype html>
+<title>Prompt when beforeunload is canceled</title>
+<script>
+addEventListener("beforeunload",
+function(e) {e.preventDefault()},
+false);
+</script>
+<p>When clicking the button below, you should get a prompt asking if you want to unload the document</p>
+<form method="get" action="next.html">
+<input type="submit" value="Click here">
+</form>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-004.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-004.html
new file mode 100644
index 000000000..a4d296892
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-004.html
@@ -0,0 +1,11 @@
+<!doctype html>
+<title>Prompt on form submit</title>
+<script>
+addEventListener("beforeunload",
+function(e) {e.preventDefault()},
+false);
+</script>
+<p>When clicking the button below, you should get a prompt asking if you want to unload the document</p>
+<form method="get" action="next.html">
+<input type="submit" value="Click here">
+</form>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-005.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-005.html
new file mode 100644
index 000000000..71ff0a241
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-005.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<title>Event loop pause for beforeunload</title>
+<script>
+var counter = 0;
+
+onload = function count() {
+ document.getElementById("log").textContent = counter++
+ setTimeout(count, 200);
+}
+
+addEventListener("beforeunload",
+function(e) {
+ e.preventDefault()
+},
+false);
+</script>
+<ul>
+<li>Click on the link below. When the prompt appears the counter at the bottom must stop incrementing.
+<li>Opt not to leave the page. The counter must start incrementing again
+</ul>
+<p><a href="">Click here</a>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-006.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-006.html
new file mode 100644
index 000000000..dae0340ad
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-006.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<title>Prompt when beforeunload returns string value</title>
+<script>
+addEventListener("beforeunload",
+function(e) {return "PASS if you see this"},
+false);
+</script>
+<p>When clicking the link below, you should get a prompt asking if you want to unload the document</p>
+<a href="next.html">Click here</a>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/next.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/next.html
new file mode 100644
index 000000000..38e7cdd5e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/next.html
@@ -0,0 +1,2 @@
+<!doctype html>
+<p>You should have seen a prompt asking you to unload the previous document
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/001-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/001-1.html
new file mode 100644
index 000000000..72f41ae3e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/001-1.html
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML>
+<script>
+ t = opener.t;
+ do_test = t.step(function () {
+ localStorage.test6564729 += '4';
+ var d = document;
+ var e = document.open(); // has no effect (ignore-opens-during-unload > 0)
+ localStorage.test6564729 += (e == d) ? '5' : 'A [' + e + '] ';
+ document.write('FAIL - document.write executed and blocked navigation!'); // has no effect (ignore-opens-during-unload > 0)
+ localStorage.test6564729 += document.body.textContent.match('FAIL') ? 'B' : '6';
+ document.close(); // has no effect (no script-created parser)
+ localStorage.test6564729 += '7';
+ })
+onload = t.step_func(function() {
+ localStorage.test6564729 = '0';
+ setTimeout(t.step_func(function() {document.links[0].click()}));
+});
+</script>
+<body onbeforeunload="localStorage.test6564729 += '1'"
+ onpagehide="localStorage.test6564729 += '3'"
+ onunload="do_test()">
+<p><a href="001a.html">Follow this link to run the test.</a>
+<p><iframe src="001b.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/001a.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/001a.html
new file mode 100644
index 000000000..36d4188b9
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/001a.html
@@ -0,0 +1,7 @@
+<!DOCTYPE HTML>
+<script>
+opener.t.step(function() {
+ opener.assert_equals(localStorage.test6564729, '0123456789');
+ opener.t.done();
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/001b.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/001b.html
new file mode 100644
index 000000000..eaafc371a
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/001b.html
@@ -0,0 +1,5 @@
+<!DOCTYPE HTML>
+<body onbeforeunload="localStorage.test6564729 += '2'"
+ onpagehide="localStorage.test6564729 += '8'"
+ onunload="localStorage.test6564729 += '9'">
+<p>Inner frame \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/002-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/002-1.html
new file mode 100644
index 000000000..0e6f7d967
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/002-1.html
@@ -0,0 +1,28 @@
+<!DOCTYPE HTML>
+<script>
+ var t = opener.t;
+
+ var do_test = t.step_func(function() {
+ localStorage.test6564729 += '1';
+ var d = document;
+ var e = document.open(); // unload triggered here - beforeunload 2, 3 in 002b; pagehide 4, unload 5, pagehide 6 in 002b, unload 7 in 002b
+ localStorage.test6564729 += (e == d) ? '8' : 'X';
+ var s = 'FAIL if you see this | ' + localStorage.test6564729;
+ document.write(s);
+ localStorage.test6564729 += document.body.textContent == s ? '9' : 'x';
+ document.close();
+ localStorage.test6564729 += 'Z';
+ document.body.textContent += ' // ' + localStorage.test6564729;
+ location = '002a.html'; // unload triggers again here, but they're not registered event listeners any more
+ });
+
+onload = t.step_func(function() {
+ localStorage.test6564729 = '0';
+ setTimeout(function() {document.getElementsByTagName("input")[0].click()}, 100);
+});
+</script>
+<body onbeforeunload="localStorage.test6564729 += '2'"
+ onpagehide="localStorage.test6564729 += '4'"
+ onunload="localStorage.test6564729 += '5'">
+<input type=button value="Activate this button to run the test" onclick="do_test()">
+<p><iframe src="002b.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/002a.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/002a.html
new file mode 100644
index 000000000..d11f67086
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/002a.html
@@ -0,0 +1,7 @@
+<!DOCTYPE HTML>
+<script>
+ opener.t.step(function() {
+ opener.assert_equals(localStorage.test6564729, '0123456789Z');
+ opener.t.done();
+ });
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/002b.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/002b.html
new file mode 100644
index 000000000..d08a7a8ad
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/002b.html
@@ -0,0 +1,5 @@
+<!DOCTYPE HTML>
+<body onbeforeunload="localStorage.test6564729 += '3'"
+ onpagehide="localStorage.test6564729 += '6'"
+ onunload="localStorage.test6564729 += '7'">
+<p>Inner frame \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/003-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/003-1.html
new file mode 100644
index 000000000..b3a4754b8
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/003-1.html
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML>
+<script>
+ var t = opener.t;
+ var do_test = t.step_func(function() {
+ localStorage.test6564729 += '1';
+ var d = document;
+ var e = document.open(); // has no effect (ignore-opens-during-unload > 0 because we're in beforeunload)
+ localStorage.test6564729 += (e == d) ? '2' : 'A [' + e + '] ';
+ document.write('FAIL - document.write executed and blocked navigation!'); // has no effect (ignore-opens-during-unload > 0)
+ localStorage.test6564729 += document.body.textContent.match('FAIL') ? 'B' : '3';
+ document.close(); // has no effect (no script-created parser)
+ localStorage.test6564729 += '4';
+ })
+
+ onload=t.step_func(function() {localStorage.test6564729 = '0'; setTimeout(t.step_func(function() {document.links[0].click()}), 100)})
+
+</script>
+<body
+ onbeforeunload="do_test()"
+ onpagehide="localStorage.test6564729 += '6'"
+ onunload="localStorage.test6564729 += '7'">
+<p><a href="003a.html">Follow this link to run the test.</a>
+<p><iframe src="003b.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/003a.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/003a.html
new file mode 100644
index 000000000..5393fa221
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/003a.html
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML>
+<p>FAIL</p>
+<script>
+opener.t.step(function() {
+ opener.assert_equals(localStorage.test6564729, '0123456789')
+ opener.t.done();
+})
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/003b.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/003b.html
new file mode 100644
index 000000000..c8f1917b8
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/003b.html
@@ -0,0 +1,5 @@
+<!DOCTYPE HTML>
+<body onbeforeunload="localStorage.test6564729 += '5'"
+ onpagehide="localStorage.test6564729 += '8'"
+ onunload="localStorage.test6564729 += '9'">
+<p>Inner frame \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/004-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/004-1.html
new file mode 100644
index 000000000..06aba08af
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/004-1.html
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML>
+<script>
+ var t = opener.t;
+ var do_test = t.step_func(function() {
+ localStorage.test6564729 += 'B';
+ var d = document;
+ var e = document.open(); // unload triggered here - beforeunload C, D in 004b; pagehide E, unload F, pagehide G in 004b, unload HIJK in 004b
+ localStorage.test6564729 += (e == d) ? 'L' : 'Y';
+ var s = 'FAIL if you see this | ' + localStorage.test6564729;
+ document.write(s);
+ localStorage.test6564729 += document.body.textContent == s ? 'M' : 'y';
+ document.close();
+ localStorage.test6564729 += 'N';
+ location = '004a.html'; // unload triggers again here, but they're not registered event listeners any more
+ })
+onload = t.step_func(function() {
+ localStorage.test6564729 = 'A';
+ setTimeout(t.step_func(function() {document.getElementsByTagName("input")[0].click()}), 100);
+})
+</script>
+<body onbeforeunload="localStorage.test6564729 += 'C'"
+ onpagehide="localStorage.test6564729 += 'E'"
+ onunload="localStorage.test6564729 += 'F'">
+<input type=button value="Activate this button to run the test" onclick="do_test()">
+<p><iframe src="004b.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/004a.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/004a.html
new file mode 100644
index 000000000..117e2b94a
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/004a.html
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML>
+<p>FAIL</p>
+<script>
+opener.t.step(function() {
+ opener.assert_equals(localStorage.test6564729, 'ABCDEFGHIJKLMN');
+ opener.t.done();
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/004b.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/004b.html
new file mode 100644
index 000000000..788937a0b
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/004b.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<script>
+ function testRun() {
+ localStorage.test6564729 += 'H';
+ var d = parent.document;
+ var e = parent.document.open(); // no effect, since that document is already in unload
+ localStorage.test6564729 += (e == d) ? 'I' : 'X';
+ var s = 'FAIL';
+ document.write(s);
+ localStorage.test6564729 += document.body.textContent == s ? 'x' : 'J';
+ document.close();
+ localStorage.test6564729 += 'K';
+ }
+</script>
+<body onbeforeunload="localStorage.test6564729 += 'D'"
+ onpagehide="localStorage.test6564729 += 'G'"
+ onunload="testRun()">
+<p>Inner frame \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/005-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/005-1.html
new file mode 100644
index 000000000..7b81a9f11
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/005-1.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<script>
+onload = opener.t.step_func(function() {
+ localStorage.test6564729 = '0'
+ setTimeout(opener.t.step_func(function() {document.links[0].click()}), 100);
+});
+</script>
+<body
+ onbeforeunload="localStorage.test6564729 += '1'"
+ onpagehide="localStorage.test6564729 += '3'"
+ onunload="localStorage.test6564729 += '4'">
+<p><a href="005a.html">Follow this link to run the test.</a>
+<p><iframe src="005b.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/005a.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/005a.html
new file mode 100644
index 000000000..5185d3b92
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/005a.html
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML>
+<p>FAIL</p>
+<script>
+opener.t.step(function() {
+ opener.assert_equals(localStorage.test6564729, '012345678')
+ opener.t.done();
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/005b.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/005b.html
new file mode 100644
index 000000000..476e8e38c
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/005b.html
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML>
+<script>
+ var t = parent.opener.t;
+ var do_test = t.step_func(function () {
+ localStorage.test6564729 += '5';
+ var s = 'FAIL: document.open() has canceled the navigation (' + localStorage.test6564729 + ')';
+ parent.document.open();
+ parent.document.write(s);
+ parent.document.close();
+ localStorage.test6564729 += parent.document.body.textContent.match('FAIL') == s ? 'X' : '6';
+ localStorage.test6564729 += '7';
+ });
+</script>
+<body onbeforeunload="localStorage.test6564729 += '2'"
+ onpagehide="do_test()"
+ onunload="localStorage.test6564729 += '8'">
+<p>Inner frame
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/001-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/001-1.html
new file mode 100644
index 000000000..74ba43954
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/001-1.html
@@ -0,0 +1,4 @@
+<!doctype html>
+<script>
+addEventListener("pagehide", parent.t.step_func(function() {parent.pagehide_fired = true}), false);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/001-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/001-2.html
new file mode 100644
index 000000000..90e28ab7f
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/001-2.html
@@ -0,0 +1,2 @@
+<!doctype html>
+Filler
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/001.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/001.html
new file mode 100644
index 000000000..444a2770c
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/001.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<title>pagehide event on unload</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+pagehide_fired = false;
+var t = async_test();
+
+onload = function() {setTimeout(function() {
+ var iframe = document.getElementsByTagName("iframe")[0]
+
+ iframe.onload = function() {
+ setTimeout(function() {
+ iframe.contentWindow.location="001-2.html";
+ }, 100);
+ iframe.onload = t.step_func(function() {assert_true(pagehide_fired); t.done()});
+ };
+
+ iframe.src = "001-1.html?" + Math.random();
+
+}, 100)};
+
+</script>
+<iframe></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/002-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/002-1.html
new file mode 100644
index 000000000..fd8e2b726
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/002-1.html
@@ -0,0 +1,4 @@
+<!doctype html>
+<script>
+addEventListener("pagehide", parent.t.step_func(parent.do_test()), false);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/002.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/002.html
new file mode 100644
index 000000000..3fb07e484
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/002.html
@@ -0,0 +1,33 @@
+<!doctype html>
+<title>pagehide event properties</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+
+onload = function() {setTimeout(function() {
+ var iframe = document.getElementsByTagName("iframe")[0]
+
+ iframe.onload = function() {
+ setTimeout(function() {
+ iframe.contentWindow.location="001-2.html";
+ }, 100);
+ iframe.onload = t.step_func(function() {t.done()});
+ };
+
+ function do_test(e) {
+ assert_equals(e.type, "pagehide");
+ assert_equals(e.target, iframe.contentDocument);
+ assert_equals(e.currentTarget, iframe.contentWindow);
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+ assert_true(e.persisted, "persisted");
+ }
+
+ iframe.src = "002-1.html?" + Math.random();
+
+}, 100)};
+
+</script>
+<iframe></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/003-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/003-1.html
new file mode 100644
index 000000000..9838c7945
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/003-1.html
@@ -0,0 +1,4 @@
+<!doctype html>
+<script>
+addEventListener("unload", parent.t.step_func(function(e) {parent.do_test(e)}), false);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/003.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/003.html
new file mode 100644
index 000000000..97821be48
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/003.html
@@ -0,0 +1,33 @@
+<!doctype html>
+<title>unload event properties</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+var do_test;
+
+onload = function() {setTimeout(function() {
+ var iframe = document.getElementsByTagName("iframe")[0]
+
+ iframe.onload = function() {
+ setTimeout(function() {
+ iframe.contentWindow.location="002-2.html";
+ }, 100);
+ iframe.onload = t.step_func(function() {t.done()});
+ };
+
+ do_test = function(e) {
+ assert_equals(e.type, "unload");
+ assert_equals(e.target, iframe.contentDocument);
+ assert_equals(e.currentTarget, iframe.contentWindow);
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+ }
+
+ iframe.src = "003-1.html?" + Math.random();
+
+}, 100)};
+
+</script>
+<iframe></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/004-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/004-1.html
new file mode 100644
index 000000000..5d0497556
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/004-1.html
@@ -0,0 +1,5 @@
+<!doctype html>
+<script>
+addEventListener("pagehide", function() {parent.events.push("pagehide"); setTimeout(function() {parent.events.push("timeout")}, 0)}, false);
+addEventListener("unload", function() {parent.events.push("unload")}, false);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/004.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/004.html
new file mode 100644
index 000000000..301baa3b8
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/004.html
@@ -0,0 +1,28 @@
+<!doctype html>
+<title>pagehide / unload event order</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+
+var events = [];
+
+onload = function() {setTimeout(function() {
+ var iframe = document.getElementsByTagName("iframe")[0]
+
+ iframe.onload = function() {
+ setTimeout(function() {
+ iframe.contentWindow.location="001-2.html";
+ }, 100);
+ iframe.onload = t.step_func(function() {
+ assert_array_equals(events, ["pagehide", "unload"])
+ t.done()});
+ };
+
+ iframe.src = "004-1.html?" + Math.random();
+
+}, 100)};
+
+</script>
+<iframe></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/006-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/006-1.html
new file mode 100644
index 000000000..8d2659623
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/006-1.html
@@ -0,0 +1,20 @@
+<!doctype html>
+006-1
+<script>
+onpagehide = function() {
+ onpagehide = null;
+ setTimeout(function() {
+ parent.t.done()
+ }, 1000);
+}
+onload = function() {
+ if (!parent.loaded) {
+ parent.loaded = true;
+ setTimeout(parent.t.step_func(
+ function() {
+ location="006-2.html?" + Math.random();
+ }
+ ), 100);
+ }
+}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/006-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/006-2.html
new file mode 100644
index 000000000..52365e55d
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/006-2.html
@@ -0,0 +1,5 @@
+<!doctype html>
+006-2
+<script>
+onload = function() {setTimeout(parent.t.step_func(function() {history.go(-1)}), 100)}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/006.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/006.html
new file mode 100644
index 000000000..c9e4d68a1
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/006.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<title>salvagable state of document after setting pagehide listener</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+
+var loaded = false;
+
+onload = function() {setTimeout(function() {
+ var iframe = document.getElementsByTagName("iframe")[0]
+ onload = null;
+ iframe.src="006-1.html?" + Math.random();
+}, 100)};
+
+</script>
+<iframe></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/007-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/007-1.html
new file mode 100644
index 000000000..ed19f4498
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/007-1.html
@@ -0,0 +1,21 @@
+<!doctype html>
+007-1
+<script>
+onunload = function() {
+ onunload = null;
+ parent.unload_fired = true;
+ setTimeout(function() {
+ parent.timeout_fired = true;
+ }, 100);
+}
+onload = function() {
+ if (!parent.loaded) {
+ parent.loaded = true;
+ setTimeout(parent.t.step_func(
+ function() {
+ location="007-2.html?" + Math.random();
+ }
+ ), 100);
+ }
+}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/007-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/007-2.html
new file mode 100644
index 000000000..f74cd1e67
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/007-2.html
@@ -0,0 +1,5 @@
+<!doctype html>
+007-2
+<script>
+onload = function() {setTimeout(parent.t.step_func(function() {parent.start_test(); history.go(-1)}), 100)}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/007.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/007.html
new file mode 100644
index 000000000..0d5b72e0f
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/007.html
@@ -0,0 +1,28 @@
+<!doctype html>
+<title>salvagable state of document after setting unload listener</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test(undefined, {timeout:2000});
+
+var loaded = false;
+var unload_fired = false;
+var timeout_fired = false;
+
+function start_test() {
+ setTimeout(t.step_func(function() {
+ assert_true(unload_fired);
+ assert_false(timeout_fired);
+ t.done()
+ }), 1000);
+}
+
+onload = function() {setTimeout(function() {
+ var iframe = document.getElementsByTagName("iframe")[0]
+ onload = null;
+ iframe.src="007-1.html?" + Math.random();
+}, 100)};
+
+</script>
+<iframe></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/008-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/008-1.html
new file mode 100644
index 000000000..29de29c91
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/008-1.html
@@ -0,0 +1,4 @@
+<!doctype html>
+<script>
+onpagehide = parent.t.step_func(function() {parent.t.done()});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/008.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/008.html
new file mode 100644
index 000000000..015507d81
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/008.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<title>pagehide IDL attribute</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var iframe;
+var t = async_test();
+onload = function() {
+ setTimeout(function() {
+ var iframe = document.getElementsByTagName("iframe")[0];
+ iframe.src="about:blank";
+ }, 100)
+};
+</script>
+<iframe src="008-1.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/009-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/009-1.html
new file mode 100644
index 000000000..d69a05914
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/009-1.html
@@ -0,0 +1,4 @@
+<!doctype html>
+<script>
+onunload = parent.t.step_func(function() {parent.t.done()});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/009.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/009.html
new file mode 100644
index 000000000..0e93e0470
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/009.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<title>unload IDL attribute</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var iframe;
+var t = async_test();
+onload = function() {
+ setTimeout(function() {
+ var iframe = document.getElementsByTagName("iframe")[0];
+ iframe.src="about:blank";
+ }, 100)
+}
+</script>
+<iframe src="009-1.html"></iframe>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/MANIFEST b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/MANIFEST
new file mode 100644
index 000000000..637d35cf3
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/MANIFEST
@@ -0,0 +1,21 @@
+support 001-1.html
+support 001-2.html
+001.html
+support 002-1.html
+002.html
+support 003-1.html
+003.html
+support 004-1.html
+004.html
+support 006-1.html
+support 006-2.html
+006.html
+support 007-1.html
+support 007-2.html
+007.html
+support 008-1.html
+008.html
+support 009-1.html
+009.html
+manual manual-001-1.html
+manual manual-001.html
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/manual-001-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/manual-001-1.html
new file mode 100644
index 000000000..3da0a0de3
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/manual-001-1.html
@@ -0,0 +1,2 @@
+<!doctype html>
+<p>Now go back. PASS should be displayed after a short pause
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/manual-001.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/manual-001.html
new file mode 100644
index 000000000..6d817a111
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/unload/manual-001.html
@@ -0,0 +1,5 @@
+<!doctype html>
+<title>Document salvagable state after setting pagehide handler</title>
+<script>onpagehide = function() {setTimeout(function(){document.body.innerHTML = "PASS"}, 100)}</script>
+<p>Click the link below then navigate back to this page. Shortly after returning you should see the text "PASS"</p>
+<p><A href="manual-001-1.html">Click here</a>