From 5d6adfb757dc2c7bdd200398df7a1e91db163a85 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Thu, 3 Oct 2019 11:17:51 +0000 Subject: [PATCH] Bug 1485727 [wpt PR 12645] - HTML: more tests for document.open bailout order, a=testonly Automatic update from web-platform-testsHTML: more tests for document.open bailout order (#12645) A continuation of https://github.com/web-platform-tests/wpt/pull/12240, but this treats cases when two bailout criteria compete against each other. See https://github.com/whatwg/html/issues/3818. -- wpt-commits: 45d82ab6c8893eab5a8f50aedfc20af81679cb10 wpt-pr: 12645 UltraBlame original commit: 0585d2064f4944eb21522699451509fb4e682ca5 --- testing/web-platform/meta/MANIFEST.json | 606 ++++++++ ...t-exception-vs-return-origin.sub.window.js | 1265 +++++++++++++++++ .../bailout-exception-vs-return-xml.window.js | 330 +++++ ...-custom-element-with-domain-frame.sub.html | 71 + ...chronous-script-with-domain-frame.sub.html | 33 + ...lout-order-xml-with-domain-frame.sub.xhtml | 101 ++ ...er-xml-with-synchronous-script-frame.xhtml | 101 ++ 7 files changed, 2507 insertions(+) create mode 100644 testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/bailout-exception-vs-return-origin.sub.window.js create mode 100644 testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/bailout-exception-vs-return-xml.window.js create mode 100644 testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/bailout-order-custom-element-with-domain-frame.sub.html create mode 100644 testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/bailout-order-synchronous-script-with-domain-frame.sub.html create mode 100644 testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/bailout-order-xml-with-domain-frame.sub.xhtml create mode 100644 testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/bailout-order-xml-with-synchronous-script-frame.xhtml diff --git a/testing/web-platform/meta/MANIFEST.json b/testing/web-platform/meta/MANIFEST.json index cc35c75d2f55a..e71fbbd03e2b1 100644 --- a/testing/web-platform/meta/MANIFEST.json +++ b/testing/web-platform/meta/MANIFEST.json @@ -1748712,6 +1748712,52 @@ bailout - order - +custom +- +element +- +with +- +domain +- +frame +. +sub +. +html +" +: +[ +[ +{ +} +] +] +" +html +/ +webappapis +/ +dynamic +- +markup +- +insertion +/ +opening +- +the +- +input +- +stream +/ +resources +/ +bailout +- +order +- synchronous - script @@ -1748748,6 +1748794,140 @@ stream / resources / +bailout +- +order +- +synchronous +- +script +- +with +- +domain +- +frame +. +sub +. +html +" +: +[ +[ +{ +} +] +] +" +html +/ +webappapis +/ +dynamic +- +markup +- +insertion +/ +opening +- +the +- +input +- +stream +/ +resources +/ +bailout +- +order +- +xml +- +with +- +domain +- +frame +. +sub +. +xhtml +" +: +[ +[ +{ +} +] +] +" +html +/ +webappapis +/ +dynamic +- +markup +- +insertion +/ +opening +- +the +- +input +- +stream +/ +resources +/ +bailout +- +order +- +xml +- +with +- +synchronous +- +script +- +frame +. +xhtml +" +: +[ +[ +{ +} +] +] +" +html +/ +webappapis +/ +dynamic +- +markup +- +insertion +/ +opening +- +the +- +input +- +stream +/ +resources +/ document - open @@ -2249128,6 +2249308,158 @@ stream / bailout - +exception +- +vs +- +return +- +origin +. +sub +. +window +. +js +" +: +[ +[ +" +/ +html +/ +webappapis +/ +dynamic +- +markup +- +insertion +/ +opening +- +the +- +input +- +stream +/ +bailout +- +exception +- +vs +- +return +- +origin +. +sub +. +window +. +html +" +{ +} +] +] +" +html +/ +webappapis +/ +dynamic +- +markup +- +insertion +/ +opening +- +the +- +input +- +stream +/ +bailout +- +exception +- +vs +- +return +- +xml +. +window +. +js +" +: +[ +[ +" +/ +html +/ +webappapis +/ +dynamic +- +markup +- +insertion +/ +opening +- +the +- +input +- +stream +/ +bailout +- +exception +- +vs +- +return +- +xml +. +window +. +html +" +{ +} +] +] +" +html +/ +webappapis +/ +dynamic +- +markup +- +insertion +/ +opening +- +the +- +input +- +stream +/ +bailout +- side - effects @@ -4020382,6 +4020714,92 @@ stream / bailout - +exception +- +vs +- +return +- +origin +. +sub +. +window +. +js +" +: +[ +" +0e1c54b683257aea8fd58c893957acd794cc1ab1 +" +" +testharness +" +] +" +html +/ +webappapis +/ +dynamic +- +markup +- +insertion +/ +opening +- +the +- +input +- +stream +/ +bailout +- +exception +- +vs +- +return +- +xml +. +window +. +js +" +: +[ +" +3558397410edea6eaa9e73fa6d0293cc7e4d48ba +" +" +testharness +" +] +" +html +/ +webappapis +/ +dynamic +- +markup +- +insertion +/ +opening +- +the +- +input +- +stream +/ +bailout +- side - effects @@ -4021128,6 +4021546,54 @@ bailout - order - +custom +- +element +- +with +- +domain +- +frame +. +sub +. +html +" +: +[ +" +4de97e8ed1bb99fd6eb2efa6dbe43bb1eb05edea +" +" +support +" +] +" +html +/ +webappapis +/ +dynamic +- +markup +- +insertion +/ +opening +- +the +- +input +- +stream +/ +resources +/ +bailout +- +order +- synchronous - script @@ -4021166,6 +4021632,146 @@ stream / resources / +bailout +- +order +- +synchronous +- +script +- +with +- +domain +- +frame +. +sub +. +html +" +: +[ +" +7ca7b5f44c518d7251c4cc47bb9d41976dd8bfc7 +" +" +support +" +] +" +html +/ +webappapis +/ +dynamic +- +markup +- +insertion +/ +opening +- +the +- +input +- +stream +/ +resources +/ +bailout +- +order +- +xml +- +with +- +domain +- +frame +. +sub +. +xhtml +" +: +[ +" +b054c0fe3a1e6b34127c83561140c06963f2dbfc +" +" +support +" +] +" +html +/ +webappapis +/ +dynamic +- +markup +- +insertion +/ +opening +- +the +- +input +- +stream +/ +resources +/ +bailout +- +order +- +xml +- +with +- +synchronous +- +script +- +frame +. +xhtml +" +: +[ +" +00fc71eccfb5e967f006d217f59577f086ac42ef +" +" +support +" +] +" +html +/ +webappapis +/ +dynamic +- +markup +- +insertion +/ +opening +- +the +- +input +- +stream +/ +resources +/ document - open diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/bailout-exception-vs-return-origin.sub.window.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/bailout-exception-vs-return-origin.sub.window.js new file mode 100644 index 0000000000000..f17b76dacfdd7 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/bailout-exception-vs-return-origin.sub.window.js @@ -0,0 +1,1265 @@ +document +. +domain += +" +{ +{ +host +} +} +" +; +/ +/ +In +many +cases +in +this +test +we +want +to +delay +execution +of +a +piece +of +code +so +/ +/ +that +the +entry +settings +object +would +be +the +top +- +level +page +. +A +microtask +is +/ +/ +perfect +for +this +purpose +as +it +is +executed +in +the +" +clean +up +after +running +/ +/ +script +" +algorithm +which +is +generally +called +right +after +the +callback +. +function +setEntryToTopLevel +( +cb +) +{ +Promise +. +resolve +( +) +. +then +( +cb +) +; +} +async_test +( +t += +> +{ +const +iframe += +document +. +body +. +appendChild +( +document +. +createElement +( +" +iframe +" +) +) +; +t +. +add_cleanup +( +( +) += +> +{ +iframe +. +remove +( +) +; +} +) +; +iframe +. +onload += +t +. +step_func_done +( +( +) += +> +{ +/ +/ +Since +this +is +called +as +an +event +handler +on +an +element +of +this +window +/ +/ +the +entry +settings +object +is +that +of +this +browsing +context +. +assert_throws +( +" +InvalidStateError +" +( +) += +> +{ +iframe +. +contentDocument +. +open +( +) +; +} +" +opening +an +XML +document +should +throw +an +InvalidStateError +" +) +; +} +) +; +const +frameURL += +new +URL +( +" +resources +/ +bailout +- +order +- +xml +- +with +- +domain +- +frame +. +sub +. +xhtml +" +document +. +URL +) +; +frameURL +. +port += +" +{ +{ +ports +[ +http +] +[ +1 +] +} +} +" +; +iframe +. +src += +frameURL +. +href +; +} +" +document +. +open +should +throw +an +InvalidStateError +with +XML +document +even +if +it +is +cross +- +origin +" +) +; +async_test +( +t += +> +{ +const +iframe += +document +. +body +. +appendChild +( +document +. +createElement +( +" +iframe +" +) +) +; +t +. +add_cleanup +( +( +) += +> +{ +iframe +. +remove +( +) +; +} +) +; +window +. +onCustomElementReady += +t +. +step_func +( +( +) += +> +{ +window +. +onCustomElementReady += +t +. +unreached_func +( +" +onCustomElementReady +called +again +" +) +; +/ +/ +Here +the +entry +settings +object +is +still +the +iframe +' +s +as +the +function +/ +/ +is +called +from +a +custom +element +constructor +in +the +iframe +document +. +/ +/ +Delay +execution +in +such +a +way +that +makes +the +entry +settings +object +the +/ +/ +top +- +level +page +' +s +but +without +delaying +too +much +that +the +/ +/ +throw +- +on +- +dynamic +- +markup +- +insertion +counter +gets +decremented +( +which +is +/ +/ +what +this +test +tries +to +pit +against +the +cross +- +origin +document +check +) +. +/ +/ +/ +/ +" +Clean +up +after +running +script +" +is +executed +through +the +" +construct +" +Web +/ +/ +IDL +algorithm +in +" +create +an +element +" +called +by +" +create +an +element +for +a +/ +/ +token +" +in +the +parser +. +setEntryToTopLevel +( +t +. +step_func_done +( +( +) += +> +{ +assert_throws +( +" +InvalidStateError +" +( +) += +> +{ +iframe +. +contentDocument +. +open +( +) +; +} +" +opening +a +document +when +the +throw +- +on +- +dynamic +- +markup +- +insertion +counter +is +incremented +should +throw +an +InvalidStateError +" +) +; +} +) +) +; +} +) +; +const +frameURL += +new +URL +( +" +resources +/ +bailout +- +order +- +custom +- +element +- +with +- +domain +- +frame +. +sub +. +html +" +document +. +URL +) +; +frameURL +. +port += +" +{ +{ +ports +[ +http +] +[ +1 +] +} +} +" +; +iframe +. +src += +frameURL +. +href +; +} +" +document +. +open +should +throw +an +InvalidStateError +when +the +throw +- +on +- +dynamic +- +markup +- +insertion +counter +is +incremented +even +if +the +document +is +cross +- +origin +" +) +; +async_test +( +t += +> +{ +const +iframe += +document +. +body +. +appendChild +( +document +. +createElement +( +" +iframe +" +) +) +; +t +. +add_cleanup +( +( +) += +> +{ +iframe +. +remove +( +) +; +} +) +; +self +. +testSynchronousScript += +t +. +step_func +( +( +) += +> +{ +/ +/ +Here +the +entry +settings +object +is +still +the +iframe +' +s +as +the +function +/ +/ +is +synchronously +called +from +a +< +script +> +element +in +the +iframe +' +s +/ +/ +document +. +/ +/ +/ +/ +" +Clean +up +after +running +script +" +is +executed +when +the +< +/ +script +> +tag +is +/ +/ +seen +by +the +HTML +parser +. +setEntryToTopLevel +( +t +. +step_func_done +( +( +) += +> +{ +assert_throws +( +" +SecurityError +" +( +) += +> +{ +iframe +. +contentDocument +. +open +( +) +; +} +" +opening +a +same +origin +- +domain +( +but +not +same +origin +) +document +should +throw +a +SecurityError +" +) +; +} +) +) +; +} +) +; +const +frameURL += +new +URL +( +" +resources +/ +bailout +- +order +- +synchronous +- +script +- +with +- +domain +- +frame +. +sub +. +html +" +document +. +URL +) +; +frameURL +. +port += +" +{ +{ +ports +[ +http +] +[ +1 +] +} +} +" +; +iframe +. +src += +frameURL +. +href +; +} +" +document +. +open +should +throw +a +SecurityError +with +cross +- +origin +document +even +when +there +is +an +active +parser +executing +script +" +) +; +for +( +const +ev +of +[ +" +beforeunload +" +" +pagehide +" +" +unload +" +] +) +{ +async_test +( +t += +> +{ +const +iframe += +document +. +body +. +appendChild +( +document +. +createElement +( +" +iframe +" +) +) +; +t +. +add_cleanup +( +( +) += +> +{ +iframe +. +remove +( +) +; +} +) +; +iframe +. +addEventListener +( +" +load +" +t +. +step_func +( +( +) += +> +{ +iframe +. +contentWindow +. +addEventListener +( +ev +t +. +step_func +( +( +) += +> +{ +/ +/ +Here +the +entry +settings +object +should +be +the +top +- +level +page +' +s +as +/ +/ +the +callback +context +of +this +event +listener +is +the +incumbent +/ +/ +settings +object +which +is +the +this +page +. +However +due +to +a +Chrome +/ +/ +bug +( +https +: +/ +/ +crbug +. +com +/ +606900 +) +the +entry +settings +object +may +be +/ +/ +mis +- +set +to +the +iframe +' +s +. +/ +/ +/ +/ +" +Clean +up +after +running +script +" +is +called +in +the +task +that +/ +/ +navigates +. +setEntryToTopLevel +( +t +. +step_func_done +( +( +) += +> +{ +assert_throws +( +" +SecurityError +" +( +) += +> +{ +iframe +. +contentDocument +. +open +( +) +; +} +" +opening +a +same +origin +- +domain +( +but +not +same +origin +) +document +should +throw +a +SecurityError +" +) +; +} +) +) +; +} +) +) +; +iframe +. +src += +" +about +: +blank +" +; +} +) +{ +once +: +true +} +) +; +iframe +. +src += +" +http +: +/ +/ +{ +{ +host +} +} +: +{ +{ +ports +[ +http +] +[ +1 +] +} +} +/ +common +/ +domain +- +setter +. +sub +. +html +" +; +} +document +. +open +should +throw +a +SecurityError +with +cross +- +origin +document +even +when +the +ignore +- +opens +- +during +- +unload +counter +is +greater +than +0 +( +during +{ +ev +} +event +) +) +; +} diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/bailout-exception-vs-return-xml.window.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/bailout-exception-vs-return-xml.window.js new file mode 100644 index 0000000000000..2ac59c016ca8f --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/bailout-exception-vs-return-xml.window.js @@ -0,0 +1,330 @@ +async_test +( +t += +> +{ +const +iframe += +document +. +body +. +appendChild +( +document +. +createElement +( +" +iframe +" +) +) +; +t +. +add_cleanup +( +( +) += +> +{ +iframe +. +remove +( +) +; +} +) +; +self +. +testSynchronousScript += +t +. +step_func_done +( +( +) += +> +{ +assert_throws +( +" +InvalidStateError +" +( +) += +> +{ +iframe +. +contentDocument +. +open +( +) +; +} +" +opening +an +XML +document +should +throw +" +) +; +} +) +; +iframe +. +src += +" +resources +/ +bailout +- +order +- +xml +- +with +- +synchronous +- +script +- +frame +. +xhtml +" +; +} +" +document +. +open +should +throw +an +InvalidStateError +with +XML +document +even +when +there +is +an +active +parser +executing +script +" +) +; +for +( +const +ev +of +[ +" +beforeunload +" +" +pagehide +" +" +unload +" +] +) +{ +async_test +( +t += +> +{ +const +iframe += +document +. +body +. +appendChild +( +document +. +createElement +( +" +iframe +" +) +) +; +t +. +add_cleanup +( +( +) += +> +{ +iframe +. +remove +( +) +; +} +) +; +iframe +. +addEventListener +( +" +load +" +t +. +step_func +( +( +) += +> +{ +iframe +. +contentWindow +. +addEventListener +( +ev +t +. +step_func_done +( +( +) += +> +{ +assert_throws +( +" +InvalidStateError +" +( +) += +> +{ +iframe +. +contentDocument +. +open +( +) +; +} +" +opening +an +XML +document +should +throw +" +) +; +} +) +) +; +iframe +. +src += +" +about +: +blank +" +; +} +) +{ +once +: +true +} +) +; +iframe +. +src += +" +/ +common +/ +dummy +. +xhtml +" +; +} +document +. +open +should +throw +an +InvalidStateError +with +XML +document +even +when +the +ignore +- +opens +- +during +- +unload +counter +is +greater +than +0 +( +during +{ +ev +} +event +) +) +; +} diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/bailout-order-custom-element-with-domain-frame.sub.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/bailout-order-custom-element-with-domain-frame.sub.html new file mode 100644 index 0000000000000..cead263625853 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/bailout-order-custom-element-with-domain-frame.sub.html @@ -0,0 +1,71 @@ +< +p +> +Text +< +/ +p +> +< +script +> +document +. +domain += +" +{ +{ +host +} +} +" +; +class +CustomElement +extends +HTMLElement +{ +constructor +( +) +{ +super +( +) +; +parent +. +onCustomElementReady +( +) +; +} +} +customElements +. +define +( +" +custom +- +element +" +CustomElement +) +; +< +/ +script +> +< +custom +- +element +> +< +/ +custom +- +element +> diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/bailout-order-synchronous-script-with-domain-frame.sub.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/bailout-order-synchronous-script-with-domain-frame.sub.html new file mode 100644 index 0000000000000..50336bc9f6d74 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/bailout-order-synchronous-script-with-domain-frame.sub.html @@ -0,0 +1,33 @@ +< +p +> +Text +< +/ +p +> +< +script +> +document +. +domain += +" +{ +{ +host +} +} +" +; +parent +. +testSynchronousScript +( +) +; +< +/ +script +> diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/bailout-order-xml-with-domain-frame.sub.xhtml b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/bailout-order-xml-with-domain-frame.sub.xhtml new file mode 100644 index 0000000000000..27f93d4943ad4 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/bailout-order-xml-with-domain-frame.sub.xhtml @@ -0,0 +1,101 @@ +< +? +xml +version += +" +1 +. +0 +" +encoding += +" +utf +- +8 +" +? +> +< +! +DOCTYPE +html +> +< +html +xmlns += +" +http +: +/ +/ +www +. +w3 +. +org +/ +1999 +/ +xhtml +" +> +< +head +> +< +title +> +XHTML +document +with +domain +set +< +/ +title +> +< +/ +head +> +< +body +> +< +p +> +Text +< +/ +p +> +< +script +> +document +. +domain += +" +{ +{ +host +} +} +" +; +< +/ +script +> +< +/ +body +> +< +/ +html +> diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/bailout-order-xml-with-synchronous-script-frame.xhtml b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/bailout-order-xml-with-synchronous-script-frame.xhtml new file mode 100644 index 0000000000000..c3dc64530c861 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/bailout-order-xml-with-synchronous-script-frame.xhtml @@ -0,0 +1,101 @@ +< +? +xml +version += +" +1 +. +0 +" +encoding += +" +utf +- +8 +" +? +> +< +! +DOCTYPE +html +> +< +html +xmlns += +" +http +: +/ +/ +www +. +w3 +. +org +/ +1999 +/ +xhtml +" +> +< +head +> +< +title +> +XHTML +document +with +hook +to +run +script +from +a +script +tag +< +/ +title +> +< +/ +head +> +< +body +> +< +p +> +Text +< +/ +p +> +< +script +> +parent +. +testSynchronousScript +( +) +; +< +/ +script +> +< +/ +body +> +< +/ +html +>