@@ -744,56 +744,86 @@ QUnit.test( "contents()", function( assert ) {
744744} ) ;
745745
746746QUnit . test ( "contents() for <template />" , function ( assert ) {
747- assert . expect ( 4 ) ;
747+ assert . expect ( 4 ) ;
748748
749- jQuery ( "#qunit-fixture" ) . append (
750- "<template id='template'>" +
751- " <div id='template-div0'>" +
752- " <span>Hello, Web Component!</span>" +
753- " </div>" +
754- " <div id='template-div1'></div>" +
755- " <div id='template-div2'></div>" +
756- "</template>"
757- ) ;
749+ jQuery ( "#qunit-fixture" ) . append (
750+ "<template id='template'>" +
751+ " <div id='template-div0'>" +
752+ " <span>Hello, Web Component!</span>" +
753+ " </div>" +
754+ " <div id='template-div1'></div>" +
755+ " <div id='template-div2'></div>" +
756+ "</template>"
757+ ) ;
758758
759- var contents = jQuery ( "#template" ) . contents ( ) ;
760- assert . equal ( contents . length , 6 , "Check template element contents" ) ;
759+ var contents = jQuery ( "#template" ) . contents ( ) ;
760+ assert . equal ( contents . length , 6 , "Check template element contents" ) ;
761761
762- assert . equal ( contents . find ( "span" ) . text ( ) , "Hello, Web Component!" , "Find span in template and check its text" ) ;
762+ assert . equal ( contents . find ( "span" ) . text ( ) , "Hello, Web Component!" , "Find span in template and check its text" ) ;
763763
764- jQuery ( "<div id='templateTest' />" ) . append (
765- jQuery ( jQuery . map ( contents , function ( node ) {
766- return document . importNode ( node , true ) ;
767- } ) )
768- ) . appendTo ( "#qunit-fixture" ) ;
764+ jQuery ( "<div id='templateTest' />" ) . append (
765+ jQuery ( jQuery . map ( contents , function ( node ) {
766+ return document . importNode ( node , true ) ;
767+ } ) )
768+ ) . appendTo ( "#qunit-fixture" ) ;
769769
770- contents = jQuery ( "#templateTest" ) . contents ( ) ;
771- assert . equal ( contents . length , 6 , "Check cloned nodes of template element contents" ) ;
770+ contents = jQuery ( "#templateTest" ) . contents ( ) ;
771+ assert . equal ( contents . length , 6 , "Check cloned nodes of template element contents" ) ;
772772
773- assert . equal ( contents . filter ( "div" ) . length , 3 , "Count cloned elements from template" ) ;
773+ assert . equal ( contents . filter ( "div" ) . length , 3 , "Count cloned elements from template" ) ;
774774} ) ;
775775
776- QUnit [ "content" in document . createElement ( "template" ) ? "test" : "skip" ] (
777- "contents() for <template /> remains inert" ,
778- function ( assert ) {
779- assert . expect ( 2 ) ;
776+ QUnit [ "content" in document . createElement ( "template" ) ? "test" : "skip" ] ( "contents() for <template /> remains inert" , function ( assert ) {
777+ assert . expect ( 2 ) ;
780778
781- Globals . register ( "testScript" ) ;
782- Globals . register ( "testImgOnload" ) ;
779+ Globals . register ( "testScript" ) ;
780+ Globals . register ( "testImgOnload" ) ;
783781
784- jQuery ( "#qunit-fixture" ) . append (
785- "<template id='template'>" +
786- " <script>testScript = 1;</script>" +
787- " <img src='" + baseURL + "1x1.jpg' onload='testImgOnload = 1' >" +
788- "</template>"
789- ) ;
782+ jQuery ( "#qunit-fixture" ) . append (
783+ "<template id='template'>" +
784+ " <script>testScript = 1;</script>" +
785+ " <img src='" + baseURL + "1x1.jpg' onload='testImgOnload = 1' >" +
786+ "</template>"
787+ ) ;
790788
791- var content = jQuery ( "#template" ) . contents ( ) ;
789+ var content = jQuery ( "#template" ) . contents ( ) ;
792790
793- assert . strictEqual ( window . testScript , true , "script in template isn't executed" ) ;
794- assert . strictEqual ( window . testImgOnload , true , "onload of image in template isn't executed" ) ;
795- }
796- ) ;
791+ assert . strictEqual ( window . testScript , true , "script in template isn't executed" ) ;
792+ assert . strictEqual ( window . testImgOnload , true , "onload of image in template isn't executed" ) ;
793+ } ) ;
794+
795+ QUnit . test ( "contents() for <object />" , function ( assert ) {
796+ assert . expect ( 2 ) ;
797+
798+ var svgObject = jQuery ( "<object id='svg-object' data='" + baseURL + "1x1.svg'></object>" ) ;
799+ var done = assert . async ( ) ;
800+
801+ svgObject . on ( "load" , function ( ) {
802+ var contents = jQuery ( "#svg-object" ) . contents ( ) ;
803+ assert . equal ( contents . length , 1 , "Check object contents" ) ;
804+ assert . equal ( contents . find ( "svg" ) . length , 1 , "Find svg within object" ) ;
805+ done ( ) ;
806+ } ) ;
807+
808+ jQuery ( "#qunit-fixture" ) . append ( svgObject ) ;
809+ } ) ;
810+
811+ QUnit . test ( "contents() for <frame />" , function ( assert ) {
812+ assert . expect ( 2 ) ;
813+
814+ var iframe = jQuery ( "<iframe id='frame-contents' src='" + baseURL + "frame.html'></iframe>" ) ;
815+ var done = assert . async ( ) ;
816+
817+ iframe . on ( "load" , function ( ) {
818+ var container = jQuery ( "#frame-contents" ) . contents ( ) ;
819+ var contents = container . find ( "#test-frame" ) . contents ( ) ;
820+ assert . equal ( contents . length , 1 , "Check frame contents" ) ;
821+ assert . equal ( contents . find ( "body" ) . length , 1 , "Find body within frame" ) ;
822+ done ( ) ;
823+ } ) ;
824+
825+ jQuery ( "#qunit-fixture" ) . append ( iframe ) ;
826+ } ) ;
797827
798828QUnit . test ( "sort direction" , function ( assert ) {
799829 assert . expect ( 12 ) ;
0 commit comments