Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashes with browser capabilities #758

Merged
merged 3 commits into from
Sep 20, 2013
Merged

Conversation

echampet
Copy link

Correct https://bugzilla.xamarin.com/show_bug.cgi?id=14720 and
probably https://bugzilla.xamarin.com/show_bug.cgi?id=13014

Signed-off-by: Etienne CHAMPETIER etienne.champetier@fiducial.net
Signed-off-by: Frederic Mestayer f.mestayer@fiducial.net

in mcs/class/System.Web
make run-test PROFILE=net_2_0 ok
make run-test PROFILE=net_4_0 ok
make run-test PROFILE=net_4_5 ok

make run-test PROFILE=net_3_5 doesn't run at all on my system

@kumpera
Copy link
Contributor

kumpera commented Sep 17, 2013

Please provide unit tests for this change.

@echampet
Copy link
Author

Hi, I think I've to load browscap.ini here

public void TestFixtureSetUp ()

but i've no clue how.

get { return capabilities; }
set { capabilities = new Hashtable(value, StringComparer.OrdinalIgnoreCase); }
set {
Hashtable cap = new Hashtable (StringComparer.OrdinalIgnoreCase);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should specify the capacity parameter of the Hashtable constructor to avoid resize operations while adding keys, i.e. new Hashtable (value.Count, StringComparer.OrdinalIgnoreCase);

Before your change, this was done internally by the constructor that takes an IDictionary.

@echampet
Copy link
Author

@akoeplinger, i've just updated my commit, thanks
(tests are still ok)

@akoeplinger
Copy link
Member

The tests in the class you mentioned seem to be ignored for many years (it says "Pending fix for bug 351878", which likely refers to this item in the old Novell Bugzilla).

I think adding tests there wouldn't make sense now. Can someone from the Mono team comment if the original bug was fixed so the tests can be reenabled?

@knocte
Copy link
Contributor

knocte commented Sep 18, 2013

A lot of time has passed since then, and the runtime has been receiving lots of fixes recently, there is a chance that this bug is fixed, and you can enable those tests now, just remove the [Ignore] attribute and check if they pass (run them many times just to make sure the bug doesn't appear in any case).

@echampet
Copy link
Author

After reenabeling

in mcs/class/System.Web
make run-test PROFILE=net_2_0 FIXTURE=System.Web.AppBrowsersTest

Excluded categories: NotWorking,ValueAdd,CAS,InetAccess
..F...
Tests run: 5, Failures: 1, Not run: 0, Time: 7.874 seconds

Test Case Failures:

  1. MonoTests.System.Web.AppBrowsersTest.AppBrowsersCapabilities : NUnit.Framework.AssertionException: AppBrowsersCapabilities Mono 2 8 - please merge the ucontext_t* changes from head. #8
    Expected: "0"
    But was: null

at NUnit.Framework.Assert.That (System.Object actual, NUnit.Framework.Constraints.Constraint constraint, System.String message, System.Object[] args) [0x00020] in /opt/echange/mono/mcs/nunit24/NUnitFramework/framework/Assert.cs:2205
at NUnit.Framework.Assert.AreEqual (System.Object expected, System.Object actual, System.String message, System.Object[] args) [0x00000] in /opt/echange/mono/mcs/nunit24/NUnitFramework/framework/Assert.cs:886
at NUnit.Framework.Assert.AreEqual (System.Object expected, System.Object actual, System.String message) [0x00000] in /opt/echange/mono/mcs/nunit24/NUnitFramework/framework/Assert.cs:900
at MonoTests.System.Web.AppBrowsersTest.AppBrowsersCapabilities_OnLoad (System.Web.UI.Page p) [0x000d4] in /opt/echange/mono/mcs/class/System.Web/Test/System.Web/AppBrowsersTest.cs:84
at MonoTests.SystemWeb.Framework.PageInvoker.Invoke (MonoTests.SystemWeb.Framework.PageDelegate callback) [0x00006] in /opt/echange/mono/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/PageInvoker.cs:276
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (System.Runtime.Remoting.Proxies.RealProxy rp, IMessage msg, System.Exception& exc, System.Object[]& out_args) [0x001e9] in /opt/echange/mono/mcs/class/corlib/System.Runtime.Remoting.Proxies/RealProxy.cs:248

With the patch all 5 tests are ok
I've commented CompatBrowserIE7 (it doesn't pass)

@knocte
Copy link
Contributor

knocte commented Sep 18, 2013

Some recommendations (briefly discussed already in IRC):

  • Don't comment tests, but add them the NUnit category "NotWorking".
  • Add a test with the testcase of the bug you're fixing.
  • It's recommended that the first word of the first line of each commit message is the assembly you're working on (if working on the BCL). In this case it would be "[System.Web]".

@echampet
Copy link
Author

It's a WIP, make run-test PROFILE=net_2_0 ok
make run-test PROFILE=net_4_0 ko

@echampet
Copy link
Author

I got 'Parent not found with id = default'

throw new nBrowser.Exception(String.Format("Parent not found with id = {0}", child.ParentId));

I think it's related to the lack of Compat.browser in NET_4_*

@knocte
Copy link
Contributor

knocte commented Sep 19, 2013

Should that be fixed then? Maybe copy the Compat.browser file to all etc profile folders instead of just one, in the install make target?

@echampet
Copy link
Author

Tests for 2, 4, 4.5 are ok.
For the test case i simply reenable AppBrowsersTest.cs tests.

@knocte
Copy link
Contributor

knocte commented Sep 19, 2013

Thanks for the update!

I think it is fine that the file Compat.browser ends up triplicated in $prefix/etc, however I think it's not good to have it triplicated in the git repository, can you avoid this?

In regards to "For the test case i simply reenable AppBrowsersTest.cs tests", do any of those tests have duplicate keys in browser capabilities? If not, then you're not really adding a test for this bugfix (as Rodrigo has requested), but restoring old tests unrelated to this issue.

@echampet
Copy link
Author

The test CompatBrowserIE7 is failing because of Key duplication

@knocte
Copy link
Contributor

knocte commented Sep 19, 2013

Ah ok!

@echampet
Copy link
Author

Tests still ok, rpm creation should be ok (just modified mono-core.spec.in to include Compat.browser, also msvc/win32.xml for win*)
Please merge :)

@knocte
Copy link
Contributor

knocte commented Sep 20, 2013

Instead of

  •      if (!capabilities.Contains (key))
    
  •        capabilities.Add (key, value [key]);
    

this would be shorter (and would make the last duplicated value the one to use, instead of the first one):

  •       capabilities [key] = value [key];
    

Right?

Frederic Mestayer and others added 3 commits September 20, 2013 14:19
Correct https://bugzilla.xamarin.com/show_bug.cgi?id=14720 and
probably https://bugzilla.xamarin.com/show_bug.cgi?id=13014

Signed-off-by: Etienne CHAMPETIER <etienne.champetier@fiducial.net>
Signed-off-by: Frederic Mestayer <f.mestayer@fiducial.net>
Without that referencing browser 'Default' (parentID="Default")
in a .browser file make the app throw exceptions here
mcs/class/System.Web/System.Web.Configuration_2.0/nBrowser/Build.cs#L206

Signed-off-by: Etienne CHAMPETIER <etienne.champetier@fiducial.net>
For now mcs/class/System.Web/Test/mainsoft/NunitWebResources/adapters.browser
depends on System.Web_test_net_2_0.dll

Signed-off-by: Etienne CHAMPETIER <etienne.champetier@fiducial.net>
grendello added a commit that referenced this pull request Sep 20, 2013
Fix crashes with browser capabilities
@grendello grendello merged commit bdc4eb0 into mono:master Sep 20, 2013
@echampet echampet deleted the capabilities branch September 20, 2013 12:25
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Fix crashes with browser capabilities

Commit migrated from mono/mono@bdc4eb0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants