@@ -69,5 +69,49 @@ public async Task BooleanConversionForNumbersTakesPlace()
6969 var option = document . QuerySelector < IHtmlOptionElement > ( "option" ) ;
7070 Assert . AreEqual ( true , option . IsDisabled ) ;
7171 }
72+
73+ [ Test ]
74+ public async Task BooleanConversionForObjectsTakesPlace ( )
75+ {
76+ var service = new JavaScriptProvider ( ) ;
77+ var cfg = Configuration . Default . With ( service ) ;
78+ var html = "<!doctype html><option></option><script>document.querySelector('option').selected = this;</script>" ;
79+ var document = await BrowsingContext . New ( cfg ) . OpenAsync ( m => m . Content ( html ) ) ;
80+ var option = document . QuerySelector < IHtmlOptionElement > ( "option" ) ;
81+ Assert . AreEqual ( true , option . IsSelected ) ;
82+ }
83+
84+ [ Test ]
85+ public async Task BooleanConversionForArraysTakesPlace ( )
86+ {
87+ var service = new JavaScriptProvider ( ) ;
88+ var cfg = Configuration . Default . With ( service ) ;
89+ var html = "<!doctype html><option></option><script>document.querySelector('option').selected = [];</script>" ;
90+ var document = await BrowsingContext . New ( cfg ) . OpenAsync ( m => m . Content ( html ) ) ;
91+ var option = document . QuerySelector < IHtmlOptionElement > ( "option" ) ;
92+ Assert . AreEqual ( true , option . IsSelected ) ;
93+ }
94+
95+ [ Test ]
96+ public async Task BooleanConversionForZeroIsFalse ( )
97+ {
98+ var service = new JavaScriptProvider ( ) ;
99+ var cfg = Configuration . Default . With ( service ) ;
100+ var html = "<!doctype html><option></option><script>document.querySelector('option').selected =0;</script>" ;
101+ var document = await BrowsingContext . New ( cfg ) . OpenAsync ( m => m . Content ( html ) ) ;
102+ var option = document . QuerySelector < IHtmlOptionElement > ( "option" ) ;
103+ Assert . AreEqual ( false , option . IsSelected ) ;
104+ }
105+
106+ [ Test ]
107+ public async Task BooleanConversionForUndefinedIsFalse ( )
108+ {
109+ var service = new JavaScriptProvider ( ) ;
110+ var cfg = Configuration . Default . With ( service ) ;
111+ var html = "<!doctype html><option></option><script>document.querySelector('option').selected = undefined;</script>" ;
112+ var document = await BrowsingContext . New ( cfg ) . OpenAsync ( m => m . Content ( html ) ) ;
113+ var option = document . QuerySelector < IHtmlOptionElement > ( "option" ) ;
114+ Assert . AreEqual ( false , option . IsSelected ) ;
115+ }
72116 }
73117}
0 commit comments