Bug 428172

Summary: WebBrowser: DocumentXxxx properties broken
Product: [Mono] Mono: Class Libraries Reporter: Andy Hume <andyhume32>
Component: Windows.FormsAssignee: Andreia Vidigal Gaita <avidigal>
Status: RESOLVED FIXED QA Contact: Mono Bugs <mono-bugs>
Severity: Normal    
Priority: P5 - None CC: prakash.tripathi
Version: 2.0.x   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard: WebBrowser
Found By: --- Services Priority:
Business Priority: 38 Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Repro -- WebBrowserAH2.cs etc
Example dump
Repro -- WebBrowserAH2.cs etc
Repro -- WebBrowserAH2.cs etc
Example dump

Description Andy Hume 2008-09-21 12:50:03 UTC
The following properties don't work in WebBrowser, as tested in Windows 2.0preview+.  Not tested on Linux (I should really think about getting a working WebBrowser setup on Linux!).  Only #2 would appear possibly platform dependent.

BTW these properties were most not implemented in 1.9, so no regression.


1) get_DocumentStream uses StreamReader to read from a string DocumentText, thus uses the string as a path!  BTW once a page is loaded the error from #2 occurs when this property is accessed.

If using DocumentText to get the data it would need to be something like:
    string text = DocumentText;
    if( text == null) return null;
    System.Text.Encoding enc = … … 
    Stream s = new MemoryStream(enc.GetBytes(text), false);
But what encoding to use?  Is Document.Encoding valid?

Ideally the raw content as downloaded by the browser would be returned…

set_DocumentStream untested due to #2.


2) DocumentText (get_ and set_) fails with InvalidCastException.
base.WebHost.Document.FirstChild apparently returns a Mono.Mozilla.DOM.Node, which implements INode (and IDisposable) but not IElement…

3) DocumentTitle (get_ and set_) fails with NRE before first painted.

4) DocumentType (get_ and set_) fails with NRE before first page loaded.
Comment 1 Andy Hume 2008-09-21 12:54:12 UTC
Created attachment 240733 [details]
Repro -- WebBrowserAH2.cs etc

Repro app attached.
Compile *without* /t:winexe, e.g. with:
  gmcs /pkg:dotnet WebBrowserAH2.cs Utils.cs
Run
Hit Test->Dump All Properties
Use File->OpenUrl (!not OpenFile due to #2), wait until loaded.
Hit Test->Dump All Properties
Close
Inspect the console output, it includes the DumpAllProperties output from before the Form is shown, and the two times when the menu item was selected.  See various errors reported.  In the dump from before painted, see #1, #3, #4.  In the dump after document loaded see #2 etc.
Comment 2 Andy Hume 2008-09-21 12:57:57 UTC
Created attachment 240734 [details]
Example dump
Comment 3 Andy Hume 2008-09-21 13:09:47 UTC
Created attachment 240735 [details]
Repro -- WebBrowserAH2.cs etc

Updated version.
Comment 4 Andy Hume 2008-09-21 13:11:36 UTC
Created attachment 240736 [details]
Repro -- WebBrowserAH2.cs etc

Updated version!
Comment 5 Andy Hume 2008-09-21 13:12:13 UTC
Created attachment 240737 [details]
Example dump

Updated version.
Comment 6 Andy Hume 2008-09-21 19:03:25 UTC
BTW this app aborts at exit with the following, as do other similar apps.  Do you want that reported separately?
[[
Stacktrace:

  at (wrapper managed-to-native) System.__ComObject.ReleaseInterfaces () <0x00004>
  at (wrapper managed-to-native) System.__ComObject.ReleaseInterfaces () <0xffffffff>
  at System.__ComObject.Finalize () [0x00000] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.0\mcs\class\corlib\System\__ComObject.cs:68
  at (wrapper runtime-invoke) System.Object.runtime_invoke_void__this__ (object, intptr,intptr,intptr) <0xffffffff>

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
]]
Comment 7 Andreia Vidigal Gaita 2008-09-21 20:13:06 UTC
(In reply to comment #6 from Andy Hume)
> BTW this app aborts at exit with the following, as do other similar apps.  Do
> you want that reported separately?

Yes, please do file a separate report for this one. And thank you for all the testing :)
Comment 8 Andreia Vidigal Gaita 2008-11-21 23:52:46 UTC
Fixed on r119687