Ejemplo n.º 1
0
        internal void SetResults(ProcessedDataPackage package, int index)
        {
            lastRenderTimestamp = 0;
            if (package == null)
            {
                //  Clear();
                return;
            }

            lock (setResultsLock)
            {
                this.currentResultsIndex = index;

                if (lastPackageHashNumber != package.GetHashCode())
                {
                    this.currentResults        = null;
                    this.package               = package;
                    this.lastPackageHashNumber = package.GetHashCode();

                    if (package.ContainsKey(typeof(BrokenSourceData)) != false &&
                        String.IsNullOrEmpty(((BrokenSourceData)package[typeof(BrokenSourceData)]).PageSource) == false &&
                        ((BrokenSourceData)package[typeof(BrokenSourceData)]).InjectionBreaks != null)
                    {
                        BrokenSourceData brokenSourceData = ((BrokenSourceData)package[typeof(BrokenSourceData)]);

                        SourcePiece[] sp = new SourcePiece[brokenSourceData.InjectionBreaks.Count];
                        int           i  = 0;
                        foreach (SourcePiece s in brokenSourceData.InjectionBreaks)
                        {
                            sp[i] = s;
                            i++;
                        }
                        this.currentResults = sp;
                        SetBuffer(brokenSourceData.PageSource);
                    }
                    if (package.ContainsKey(typeof(RenderData)) != false)
                    {
                        RenderData rd = (RenderData)package[typeof(RenderData)];
                        foreach (RenderedSegment rs in rd.Values)
                        {
                            lastRenderTimestamp = Math.Max(lastRenderTimestamp, rs.EndTime);
                        }
                    }
                }

                RedrawResultsNextPrev();
            }
        }
Ejemplo n.º 2
0
        private Entry[] Get_Entries(ProcessedDataPackage package)
        {
            if (package.ContainsKey(typeof(DownloadData)) == false)
            {
                return(null);
            }

            DownloadData r = (DownloadData)package[typeof(DownloadData)];

            if (r == null)
            {
                return(null);
            }

            LinkedList <Entry> entry = new LinkedList <Entry>();

            foreach (DownloadState ds in r)
            {
                entry.AddLast(new Entry(ds, package));
            }
            return(new List <Entry>(entry).ToArray());
        }
Ejemplo n.º 3
0
        private void ShowSourcePopup(FlashCallEvent e)//s+","+l
        {
            if (package == null || package.ContainsKey(typeof(BrokenSourceData)) == false)
            {
                return;
            }

            Match m = requestParserShowSourcePopup.Match(e.request);

            if (m.Success == false || m.Groups.Count != 2)
            {
                return;
            }

            lock (showSourcePopupLock)
            {
                PageSourceViewForm form = null;

                foreach (Form opnFrm in Application.OpenForms)
                {
                    if (opnFrm is PageSourceViewForm)
                    {
                        form = (PageSourceViewForm)opnFrm;
                        break;
                    }
                }

                if (form == null)
                {
                    form = new PageSourceViewForm();
                    form.Show();
                }

                form.SetResults(package, int.Parse(m.Groups[1].Value));
                form.Focus();
            }
        }
Ejemplo n.º 4
0
        private void ProcessResults(ProcessedDataPackage package)
        {
            IConfigGetter getter = ConfigProvider.Instance.GetConfigGetter("MSFast.Global");

            if (getter == null)
            {
                SetTestRunning(false);
                SetTestStatus(TestEventType.TestEnded, false, PageDataCollectorErrors.InvalidConfiguration, -1);
            }

            #region Collected Data

            String graphResults = null;

            if (getter.GetBoolean(MSFastGlobalConfigKeys.PAGE_GRAPH))
            {
                if (package.ContainsKey(typeof(DownloadData)) != false ||
                    package.ContainsKey(typeof(RenderData)) != false ||
                    package.ContainsKey(typeof(PerformanceData)) != false)
                {
                    SerializedResultsFilesInfo srfi = new SerializedResultsFilesInfo(package);

                    if (String.IsNullOrEmpty(srfi.GetFolderNameAndCheckIfValid()))
                    {
                        SetTestRunning(false);
                        SetTestStatus(TestEventType.TestEnded, false, PageDataCollectorErrors.InvalidConfiguration, -1);
                        return;
                    }

                    package.ThumbnailsRoot = "file://" + srfi.GetFolderNameAndCheckIfValid();

                    XmlDocument x = package.Serialize();

                    if (x == null)
                    {
                        SetTestRunning(false);
                        SetTestStatus(TestEventType.TestEnded, false, PageDataCollectorErrors.Unknown, -1);
                        return;
                    }

                    try
                    {
                        x.Save(srfi.GetFullPath());
                        graphResults = srfi.GetFullPath();
                    }
                    catch
                    {
                        SetTestRunning(false);
                        SetTestStatus(TestEventType.TestEnded, false, PageDataCollectorErrors.Unknown, -1);
                        return;
                    }
                }
            }
            #endregion

            #region Validation

            ValidationResultsPackage validationResults = null;

            if (getter.GetBoolean(MSFastGlobalConfigKeys.PAGE_VALIDATION))
            {
                if (validationRunner == null)
                {
                    CreateValidationRunner();
                }

                if (validationRunner != null)
                {
                    validationResults = validationRunner.ValidateBlocking(package);
                }
            }

            #endregion

            SetTestRunning(false);
            SetTestStatus(TestEventType.TestEnded, true);

            ShowOutcome(graphResults, validationResults, package);
        }
Ejemplo n.º 5
0
        public void OnData(string p)
        {
            try
            {
                if (package == null)
                {
                    return;
                }

                Match match = null;

                if (score == -1 && (match = RESULTS.Match(p)) != null && match.Success)
                {
                    this.score = int.Parse(match.Groups[1].Value);
                    return;
                }

                if (score != -1 && results == null)
                {
                    if (SOURCE.IsMatch(p))
                    {
                        results = new ValidationResults <SourceValidationOccurance>();
                    }
                    else if (DOWNLOAD.IsMatch(p))
                    {
                        results = new ValidationResults <DownloadStateOccurance>();
                    }

                    if (results != null)
                    {
                        results.Score = this.score;
                    }
                }



                if (results is ValidationResults <DownloadStateOccurance> &&
                    package.ContainsKey(typeof(DownloadData)) &&
                    (match = DOWNLOAD.Match(p)) != null && match.Success)
                {
                    String url = match.Groups[1].Value;

                    DownloadData  dd = package[typeof(DownloadData)] as DownloadData;
                    DownloadState ds = null;

                    if (dd != null)
                    {
                        foreach (DownloadState d in dd)
                        {
                            if (String.IsNullOrEmpty(d.URL) == false && d.URL.Equals(url))
                            {
                                ds = d;
                                break;
                            }
                        }
                    }

                    if (ds != null)
                    {
                        results.Add(new DownloadStateOccurance(ds));
                    }
                }
                else if (results is ValidationResults <SourceValidationOccurance> &&
                         (package.ContainsKey(typeof(BrokenSourceData)) || package.ContainsKey(typeof(PageSourceData))) &&
                         (match = SOURCE.Match(p)) != null && match.Success)
                {
                    PageSourceData psd = null;

                    if (package.ContainsKey(typeof(BrokenSourceData)))
                    {
                        psd = (PageSourceData)package[typeof(BrokenSourceData)];
                    }

                    if (psd == null && package.ContainsKey(typeof(PageSourceData)))
                    {
                        psd = (PageSourceData)package[typeof(PageSourceData)];
                    }

                    results.Add(
                        new SourceValidationOccurance(psd,
                                                      int.Parse(match.Groups[1].Value),
                                                      int.Parse(match.Groups[2].Value))
                        );
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Error parsing validator output", e);
                }
            }
        }
Ejemplo n.º 6
0
        public IValidationResults Validate(ProcessedDataPackage package)
        {
            String jsshellExecutable = GetJSShellExecutable();

            if (String.IsNullOrEmpty(jsshellExecutable) || File.Exists(jsshellExecutable) == false)
            {
                return(null);
            }

            if (package == null)
            {
                return(null);
            }

            if (package.ContainsKey(typeof(HARCache)) == false)
            {
                HARCache c = GenerateHAR(package);
                if (c == null || String.IsNullOrEmpty(c.HARJSONObject))
                {
                    return(null);
                }
                package.Add(typeof(HARCache), c);
            }

            HARCache har = package[typeof(HARCache)] as HARCache;

            if (har == null)
            {
                return(null);
            }

            String tmpFilename = GenerateTmpFilename();

            if (String.IsNullOrEmpty(tmpFilename))
            {
                return(null);
            }

            StreamWriter sw = null;

            try
            {
                sw = new StreamWriter(File.Open(tmpFilename, FileMode.Create));

                sw.Write(har.HARJSONObject);
                sw.Write(script);
                sw.Write(String.Format("var EXTDATA = {{{0}}};\r\n", data));
                sw.Write(String.Format("var BASE_FOLDER = \"{0}\";\r\n", GetBaseFolder()));
                sw.Write("load(BASE_FOLDER + \"/JSTemplate/JavascriptValidator.js\");\r\n");

                sw.Flush();
                sw.Close();

                this.JavascriptOutputReader = new JavascriptOutputReader(package);

                ProcessStartInfo psi = new ProcessStartInfo(jsshellExecutable);
                psi.CreateNoWindow         = true;
                psi.WindowStyle            = System.Diagnostics.ProcessWindowStyle.Hidden;
                psi.UseShellExecute        = false;
                psi.Arguments              = String.Format("\"{0}\"", tmpFilename);
                psi.RedirectStandardOutput = true;
                psi.RedirectStandardError  = true;
                Process p = new Process();
                p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
                p.ErrorDataReceived  += new DataReceivedEventHandler(p_ErrorDataReceived);
                p.StartInfo           = (psi);
                p.Start();
                p.BeginErrorReadLine();
                p.BeginOutputReadLine();
                p.WaitForExit();

                return(this.JavascriptOutputReader.GetResults());
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Javascript Validator Error", e);
                }
            }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                }

                this.JavascriptOutputReader = null;

                if (File.Exists(tmpFilename))
                {
                    try
                    {
                        File.Delete(tmpFilename);
                    }
                    catch
                    {
                    }
                }
            }

            return(null);
        }