public static void CompatBrowserIE7_OnLoad(Page p)
        {
            HttpRequest          request = p.Request;
            HttpCapabilitiesBase caps    = request.Browser;

            Assert.AreEqual("added", caps["addedInIE6to9RefNode"], "CompatBrowserIE7 #1");
        }
        public static void TagWriter_OnLoad(Page p)
        {
            HttpRequest          request = p.Request;
            HttpCapabilitiesBase caps    = request.Browser;

            Assert.AreEqual(typeof(CustomHtmlTextWriter), caps.TagWriter, "TagWriter #1");
        }
Beispiel #3
0
        public static void Page_OnLoad(Page p)
        {
            HttpRequest          request = p.Request;
            HttpCapabilitiesBase caps    = request.Browser;

            Assert.IsNotNull(caps, "Loaded Capabilities");
        }
        public static void CreateHtmlTextWriter_OnLoad(Page p)
        {
            HttpRequest          request = p.Request;
            HttpCapabilitiesBase caps    = request.Browser;

            Assert.AreEqual(typeof(CustomHtmlTextWriter),
                            caps.CreateHtmlTextWriter(new StringWriter()).GetType(),
                            "CreateHtmlTextWriter #1");
        }
Beispiel #5
0
        public static void CapabilitiesUsedBySystemWebIE6_OnLoad(Page p)
        {
            HttpRequest          request = p.Request;
            HttpCapabilitiesBase caps    = request.Browser;

            Assert.IsFalse(String.IsNullOrEmpty(caps.Browser), "Browser");                   // Used in System.Web code
            Assert.IsTrue(new Version(1, 2) <= caps.EcmaScriptVersion, "EcmaScriptVersion"); // Used in System.Web code
            Assert.IsTrue(0 != caps.MajorVersion, "MajorVersion");                           // Used in System.Web code
            Assert.IsFalse(String.IsNullOrEmpty(caps.Type), "Type");                         // Used in System.Web code
            Assert.AreEqual(new Version(1, 0), caps.W3CDomVersion, "W3CDomVersion");         // Used in System.Web code
        }
 private static void SetDefaults(HttpCapabilitiesBase source)
 {
     // We'll assume a reasonable width for the browser, but we'll
     // do so before any other capabilities are detected. This way
     // our default will be overriden if an actual value is found
     // in one of our sources.
     if (!source.Capabilities.Contains(AllCapabilities.Width))
     {
         source.Capabilities[AllCapabilities.Width] = AllCapabilities.DefaultWidth.ToString(CultureInfo.InvariantCulture);
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="AspNetClientCapability"/> class.
        /// Constructs a new instance of ClientCapability.
        /// </summary>
        /// <param name="userAgent">The user agent.</param>
        /// <param name="browserCaps">The browser capabilities.</param>
        public AspNetClientCapability(string userAgent, HttpCapabilitiesBase browserCaps)
        {
            this.UserAgent = userAgent;

            if (browserCaps != null)
            {
                this.ID = browserCaps.Id;
                this.ScreenResolutionWidthInPixels  = browserCaps.ScreenPixelsWidth;
                this.ScreenResolutionHeightInPixels = browserCaps.ScreenPixelsHeight;
                this.IsTouchScreen = false;
                this.BrowserName   = browserCaps.Browser;
                if (browserCaps.Capabilities != null)
                {
                    this.Capabilities = browserCaps.Capabilities.Cast <DictionaryEntry>()
                                        .ToDictionary(kvp => Convert.ToString(kvp.Key), kvp => Convert.ToString(kvp.Value));
                }
                else
                {
                    this.Capabilities = new Dictionary <string, string>();
                }

                this.SupportsFlash   = false;
                this.HtmlPreferedDTD = null;

                if (this.UserAgent.Length < 4)
                {
                    return;
                }

                var lowerAgent = this.UserAgent.ToLowerInvariant();
                this.IsMobile = browserCaps.IsMobileDevice || GetIfMobile(lowerAgent);
                this.IsTablet = GetIfTablet(lowerAgent);

                try
                {
                    DetectOperatingSystem(lowerAgent, this.Capabilities);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                }
            }
        }
        public static void AppBrowsersCapabilities_OnLoad(Page p)
        {
            HttpRequest          request = p.Request;
            HttpCapabilitiesBase caps    = request.Browser;

            Assert.IsFalse(String.IsNullOrEmpty(caps.Browser), "Browser");
            Assert.AreEqual("testUserAgent", request.UserAgent, "AppBrowsersCapabilities #1");
            Assert.AreEqual("testUserAgent", caps[""], "AppBrowsersCapabilities #2");
            Assert.AreEqual("default", caps["notChanged"], "AppBrowsersCapabilities #3");
            Assert.AreEqual("uaInOrig:testUserAgent", caps["capturedInOrigNode"], "AppBrowsersCapabilities #4");
            Assert.AreEqual("added", caps["addedInRefNode"], "AppBrowsersCapabilities #5");
            Assert.AreEqual("changed", caps["changedInRefNode"], "AppBrowsersCapabilities #6");
            Assert.AreEqual("uaInRef:testUserAgent", caps["capturedInRefNode"], "AppBrowsersCapabilities #7");
            // This property is inherited from browscap.ini
            Assert.AreEqual("0", caps["majorver"], "AppBrowsersCapabilities #8");
            // This capability uses multiple substitutions
            Assert.AreEqual("uaInOrig:testUserAgent uaInRef:testUserAgent", caps["multipleSubstitutions"],
                            "AppBrowsersCapabilities #9");
            Assert.AreEqual("10%*$100=$10", caps["specialCharsInValue"],
                            "AppBrowsersCapabilities #10");
        }
Beispiel #9
0
        public static void CapabilitiesValues_OnLoad(Page p)
        {
            HttpRequest          request = p.Request;
            HttpCapabilitiesBase caps    = request.Browser;

            Assert.IsTrue(caps.ActiveXControls, "ActiveXControls");
            Assert.AreEqual(0, caps.Adapters.Count, "Adapters");
            Assert.IsFalse(caps.AOL, "AOL");
            Assert.IsTrue(caps.BackgroundSounds, "BackgroundSounds");
            Assert.IsFalse(caps.Beta, "Beta");
            Assert.AreEqual("IE", caps.Browser, "Browser");              // Used in System.Web code
            Assert.IsTrue(caps.Browsers.Count > 0, "Browsers.Count > 0");
            Assert.IsTrue(caps.CanCombineFormsInDeck, "CanCombineFormsInDeck");
            Assert.IsFalse(caps.CanInitiateVoiceCall, "CanInitiateVoiceCall");
            Assert.IsTrue(caps.CanRenderAfterInputOrSelectElement, "CanRenderAfterInputOrSelectElement");
            Assert.IsTrue(caps.CanRenderEmptySelects, "CanRenderEmptySelects");
            Assert.IsTrue(caps.CanRenderInputAndSelectElementsTogether, "CanRenderInputAndSelectElementsTogether");
            Assert.IsTrue(caps.CanRenderMixedSelects, "CanRenderMixedSelects");
            Assert.IsTrue(caps.CanRenderOneventAndPrevElementsTogether, "CanRenderOneventAndPrevElementsTogether");
            Assert.IsTrue(caps.CanRenderPostBackCards, "CanRenderPostBackCards");
            Assert.IsTrue(caps.CanRenderSetvarZeroWithMultiSelectionList, "CanRenderSetvarZeroWithMultiSelectionList");
            Assert.IsTrue(caps.CanSendMail, "CanSendMail");
            Assert.IsFalse(caps.CDF, "CDF");
            Assert.IsTrue(caps.Cookies, "Cookies");
            Assert.IsFalse(caps.Crawler, "Crawler");
            Assert.AreEqual(1, caps.DefaultSubmitButtonLimit, "DefaultSubmitButtonLimit");
            Assert.AreEqual(new Version(1, 2), caps.EcmaScriptVersion, "EcmaScriptVersion");              // Used in System.Web code
            Assert.IsTrue(caps.Frames, "frames");
            Assert.AreEqual(0, caps.GatewayMajorVersion, "GatewayMajorVersion");
            Assert.AreEqual(0.0, caps.GatewayMinorVersion, "GatewayMinorVersion");
            Assert.AreEqual("None", caps.GatewayVersion, "GatewayVersion");
            Assert.IsTrue(caps.HasBackButton, "HasBackButton");
            Assert.IsFalse(caps.HidesRightAlignedMultiselectScrollbars, "HidesRightAlignedMultiselectScrollbars");
            Assert.IsNull(caps.HtmlTextWriter, "HtmlTextWriter");
            Assert.AreEqual("ie6to9", caps.Id, "Id");
            Assert.AreEqual("keyboard", caps.InputType, "InputType");
            Assert.IsTrue(caps.IsColor, "IsColor");
            Assert.IsFalse(caps.IsMobileDevice, "IsMobileDevice");
            Assert.IsTrue(caps.JavaApplets, "JavaApplets");
            Assert.IsTrue(caps.JavaScript, "JavaScript");
            Assert.AreEqual(new Version(5, 6), caps.JScriptVersion, "JScriptVersion");
            Assert.AreEqual(6, caps.MajorVersion, "MajorVersion");              // Used in System.Web code
            Assert.AreEqual(10000, caps.MaximumHrefLength, "MaximumHrefLength");
            Assert.AreEqual(300000, caps.MaximumRenderedPageSize, "MaximumRenderedPageSize");
            Assert.AreEqual(5, caps.MaximumSoftkeyLabelLength, "MaximumSoftkeyLabelLength");
            Assert.AreEqual(0.0, caps.MinorVersion, "MinorVersion");
            Assert.AreEqual(".0", caps.MinorVersionString, "MinorVersionString");
            Assert.AreEqual("Unknown", caps.MobileDeviceManufacturer, "MobileDeviceManufacturer");
            Assert.AreEqual("Unknown", caps.MobileDeviceModel, "MobileDeviceModel");
            Assert.AreEqual(new Version(6, 0), caps.MSDomVersion, "MSDomVersion");
            Assert.AreEqual(0, caps.NumberOfSoftkeys, "NumberOfSoftkeys");
            Assert.AreEqual("WinXP", caps.Platform, "Platform");
            Assert.AreEqual("image/gif", caps.PreferredImageMime, "PreferredImageMime");
            Assert.AreEqual("text/html", caps.PreferredRenderingMime, "PreferredRenderingMime");
            Assert.AreEqual("html32", caps.PreferredRenderingType, "PreferredRenderingType");
            Assert.IsNull(caps.PreferredRequestEncoding, "PreferredRequestEncoding");
            Assert.IsNull(caps.PreferredResponseEncoding, "PreferredResponseEncoding");
            Assert.IsFalse(caps.RendersBreakBeforeWmlSelectAndInput, "RendersBreakBeforeWmlSelectAndInput");
            Assert.IsTrue(caps.RendersBreaksAfterHtmlLists, "RendersBreaksAfterHtmlLists");
            Assert.IsFalse(caps.RendersBreaksAfterWmlAnchor, "RendersBreaksAfterWmlAnchor");
            Assert.IsFalse(caps.RendersBreaksAfterWmlInput, "RendersBreaksAfterWmlInput");
            Assert.IsTrue(caps.RendersWmlDoAcceptsInline, "RendersWmlDoAcceptsInline");
            Assert.IsFalse(caps.RendersWmlSelectsAsMenuCards, "RendersWmlSelectsAsMenuCards");
            Assert.IsNull(caps.RequiredMetaTagNameValue, "RequiredMetaTagNameValue");
            Assert.IsFalse(caps.RequiresAttributeColonSubstitution, "RequiresAttributeColonSubstitution");
            Assert.IsFalse(caps.RequiresContentTypeMetaTag, "RequiresContentTypeMetaTag");
            Assert.IsFalse(caps.RequiresControlStateInSession, "RequiresControlStateInSession");
            Assert.IsFalse(caps.RequiresDBCSCharacter, "RequiresDBCSCharacter");
            Assert.IsFalse(caps.RequiresHtmlAdaptiveErrorReporting, "RequiresHtmlAdaptiveErrorReporting");
            Assert.IsFalse(caps.RequiresLeadingPageBreak, "RequiresLeadingPageBreak");
            Assert.IsFalse(caps.RequiresNoBreakInFormatting, "RequiresNoBreakInFormatting");
            Assert.IsFalse(caps.RequiresOutputOptimization, "RequiresOutputOptimization");
            Assert.IsFalse(caps.RequiresPhoneNumbersAsPlainText, "RequiresPhoneNumbersAsPlainText");
            Assert.IsFalse(caps.RequiresSpecialViewStateEncoding, "RequiresSpecialViewStateEncoding");
            Assert.IsFalse(caps.RequiresUniqueFilePathSuffix, "RequiresUniqueFilePathSuffix");
            Assert.IsFalse(caps.RequiresUniqueHtmlCheckboxNames, "RequiresUniqueHtmlCheckboxNames");
            Assert.IsFalse(caps.RequiresUniqueHtmlInputNames, "RequiresUniqueHtmlInputNames");
            Assert.IsFalse(caps.RequiresUrlEncodedPostfieldValues, "RequiresUrlEncodedPostfieldValues");
            Assert.AreEqual(8, caps.ScreenBitDepth, "ScreenBitDepth");
            Assert.AreEqual(40, caps.ScreenCharactersHeight, "ScreenCharactersHeight");
            Assert.AreEqual(80, caps.ScreenCharactersWidth, "ScreenCharactersWidth");
            Assert.AreEqual(480, caps.ScreenPixelsHeight, "ScreenPixelsHeight");
            Assert.AreEqual(640, caps.ScreenPixelsWidth, "ScreenPixelsWidth");
            Assert.IsFalse(caps.SupportsAccesskeyAttribute, "SupportsAccesskeyAttribute");
            Assert.IsTrue(caps.SupportsBodyColor, "SupportsBodyColor");
            Assert.IsTrue(caps.SupportsBold, "SupportsBold");
            Assert.IsTrue(caps.SupportsCacheControlMetaTag, "SupportsCacheControlMetaTag");
            Assert.IsTrue(caps.SupportsCallback, "SupportsCallback");
            Assert.IsTrue(caps.SupportsCss, "SupportsCss");
            Assert.IsTrue(caps.SupportsDivAlign, "SupportsDivAlign");
            Assert.IsTrue(caps.SupportsDivNoWrap, "SupportsDivNoWrap");
            Assert.IsTrue(caps.SupportsEmptyStringInCookieValue, "SupportsEmptyStringInCookieValue");
            Assert.IsTrue(caps.SupportsFontColor, "SupportsFontColor");
            Assert.IsTrue(caps.SupportsFontName, "SupportsFontName");
            Assert.IsTrue(caps.SupportsFontSize, "SupportsFontSize");
            Assert.IsTrue(caps.SupportsImageSubmit, "SupportsImageSubmit");
            Assert.IsFalse(caps.SupportsIModeSymbols, "SupportsIModeSymbols");
            Assert.IsFalse(caps.SupportsInputIStyle, "SupportsInputIStyle");
            Assert.IsFalse(caps.SupportsInputMode, "SupportsInputMode");
            Assert.IsTrue(caps.SupportsItalic, "SupportsItalic");
            Assert.IsFalse(caps.SupportsJPhoneMultiMediaAttributes, "SupportsJPhoneMultiMediaAttributes");
            Assert.IsFalse(caps.SupportsJPhoneSymbols, "SupportsJPhoneSymbols");
            Assert.IsTrue(caps.SupportsQueryStringInFormAction, "SupportsQueryStringInFormAction");
            Assert.IsTrue(caps.SupportsRedirectWithCookie, "SupportsRedirectWithCookie");
            Assert.IsTrue(caps.SupportsSelectMultiple, "SupportsSelectMultiple");
            Assert.IsTrue(caps.SupportsUncheck, "SupportsUncheck");
            Assert.IsTrue(caps.SupportsXmlHttp, "SupportsXmlHttp");
            Assert.IsTrue(caps.Tables, "Tables");
            Assert.AreEqual("IE6", caps.Type, "Type");              // Used in System.Web code
            Assert.IsTrue(caps.UseOptimizedCacheKey, "UseOptimizedCacheKey");
            Assert.IsTrue(caps.VBScript, "VBScript");
            Assert.AreEqual("6.0", caps.Version, "Version");
            Assert.AreEqual(new Version(1, 0), caps.W3CDomVersion, "W3CDomVersion");               // Used in System.Web code
            Assert.IsFalse(caps.Win16, "Win16");
            Assert.IsTrue(caps.Win32, "Win32");
        }