Exemplo n.º 1
0
 void IDebuggerEventSink.NotifyStackContext(IList <FrameInfo> frames)
 {
     CurrentFrames.Clear();
     foreach (var frame in frames)
     {
         CurrentFrames.Add(StackFrame.Create(frame.Name, frame.Number, frame.Scopes,
                                             CodeContext.Create(Engine, this,
                                                                Engine.FileSystem[frame.QrcPath].FilePath, (uint)frame.Line)));
     }
 }
Exemplo n.º 2
0
 public void Refresh()
 {
     CurrentFrames.ForEach(x => x.Refresh());
 }
Exemplo n.º 3
0
        public static string CurrentSwitchTo(string framePath, int retry = 1)
        {
            string[] targetFrames = framePath.Split(new char[] { ' ', '>', '$', '%' }, StringSplitOptions.RemoveEmptyEntries);

            if (Driver.Url == LastDriverUrl && !string.IsNullOrEmpty(Driver.PageSource))
            {
                if (targetFrames.Count() == CurrentFrames.Count() && targetFrames.SequenceEqual(CurrentFrames))
                {
                    return(CurrentDriverPath);
                }
            }
            else
            {
                //Means the page has been reloaded.
                Driver.SwitchTo().Window(Driver.CurrentWindowHandle);
                LastDriverUrl = Driver.Url;
                CurrentFrames.Clear();
            }

            int lastSameIndex = Math.Min(CurrentFrames.Count, targetFrames.Count()) - 1;

            string oldPath = CurrentDriverPath;

            for (int i = lastSameIndex; i >= 0; i--)
            {
                if (CurrentFrames[i] != targetFrames[i])
                {
                    lastSameIndex = i - 1;
                }
            }

            if (lastSameIndex == -1)
            {
                //Switch to the root of the loaded page
                if (CurrentFrames.Count != 0)
                {
                    Driver.SwitchTo().Window(Driver.CurrentWindowHandle);
                    //Driver.SwitchTo().DefaultContent();
                    CurrentFrames.Clear();
                }
            }
            else
            {
                //Otherwise, switch to the first parent frame that potentially contains target frame
                while (CurrentFrames.Count - 1 > lastSameIndex)
                {
                    Driver.SwitchTo().ParentFrame();
                    CurrentFrames.RemoveAt(CurrentFrames.Count - 1);
                }
            }

            for (int i = lastSameIndex + 1; i < targetFrames.Count(); i++)
            {
                string nextFrame = targetFrames[i];
                try
                {
                    Driver.SwitchTo().Frame(nextFrame);
                    CurrentFrames.Add(nextFrame);
                }
                catch (NoSuchFrameException ex)
                {
                    Logger.V("Failed to swith to frame '{0}'.", nextFrame);
                    if (retry > 0)
                    {
                        Driver.SwitchTo().Window(Driver.CurrentWindowHandle);
                        CurrentFrames.Clear();
                        return(CurrentSwitchTo(framePath, retry - 1));
                    }
                    Logger.E(ex);

                    Driver.SwitchTo().Window(Driver.CurrentWindowHandle);
                    CurrentFrames.Clear();
                }
            }

            if (oldPath != CurrentDriverPath)
            {
                Logger.V("Path switch from '{0}' to '{1}'.", oldPath, CurrentDriverPath);
            }
            LastDriverUrl = Driver.Url;
            return(CurrentDriverPath);
        }