Frameset.cs :  » Web-Testing » IeUnit-web-testing-framework » QuickFocus » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Web Testing » IeUnit web testing framework 
IeUnit web testing framework » QuickFocus » Frameset.cs
/// <copyright from="2004" to="2006" company="VisuMap Technologies Inc.">
///   Copyright (C) VisuMap Technologies Inc.
/// 
///   Permission to use, copy, modify, distribute and sell this 
///   software and its documentation for any purpose is hereby 
///   granted without fee, provided that the above copyright notice 
///   appear in all copies and that both that copyright notice and 
///   this permission notice appear in supporting documentation. 
///   VisuMap Technologies Company makes no representations about the 
///   suitability of this software for any purpose. It is provided 
///   "as is" without explicit or implied warranty. 
/// </copyright>
using System;
using System.Collections;
using mshtml;

namespace QuickFocus{
  /// <summary>
  /// Summary description for Frameset.
  /// </summary>
  public sealed class Frameset 
  {
    private Frameset() 
    {
    }

        private static string preFramePath;

        public static void Reset() {
            preFramePath = null;
        }

        public static bool IsForeignFrame(IHTMLWindow2 win) {

            try {
                if ( win.document.protocol == "File Protocol") {
                    return false;
                }

                if ( win.document.domain.Length == 0 ) {
                    return true;
                }
            } catch( UnauthorizedAccessException ) {
                return true;
            }

            return false;
        }

        public static ArrayList GetFramesetSnip(IHTMLDocument2 rootDoc, IHTMLDocument2 focusedDoc) {
            ArrayList snips = new ArrayList();
            if ( rootDoc.frames.length <= 0 ) {
                return snips;
            }
                    
            IHTMLWindow2 pwin = focusedDoc.parentWindow;

            if ( IsForeignFrame(pwin) ) {
                // We can't click or assert in a foreign frame.
                // So, no code here.
                return snips;
            }

            string framePath = "";
            while ( pwin != pwin.parent ) {
                if ( pwin.name != null ) {
                    framePath = pwin.name + "/" +  framePath;
                } else {
                    HTMLWindow2Class win2 = pwin as HTMLWindow2Class;
                    HTMLFrameElementClass frm = win2.frameElement as HTMLFrameElementClass;
                    if ( (frm != null) && (frm.id != null) ) {
                        framePath = frm.id + "/" + framePath;
                    } else {
                        object x = 1;
                        int    i;
                        for(i=0; i<pwin.parent.length; i++) {
                            x = i;
                            object f = pwin.parent.item(ref x);
                            if ( f == pwin ) {
                                break;
                            }
                        }
                        if (i<pwin.parent.length) {
                            framePath = i + "/" + framePath;
                        } else {
                            // something is wrong if we got here
                            return snips;
                        }
                    }
                }
                pwin = pwin.parent;
            }

            if ( framePath.Length > 0 ) {
                // trim the last "/" character.
                framePath = framePath.Substring(0, framePath.Length-1);
            } else {
                return snips;
            }


            if ( framePath == preFramePath ) {
                // We are still in the same frame, we don't have to issue the setFrame()
                return snips;
            } else {
                preFramePath = framePath;
            }


            snips.Add("_.setFrame(\"" + preFramePath + "\");\n");

            return snips;
        }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.