Example #1
0
 def testAsyncScriptDependency(self):
     JS_REQUEST_WITH_ASYNC_STACK = Request.FromJsonDict({
         'url':
         'http://bla.com/cat.js',
         'request_id':
         '1234.14',
         'initiator': {
             'type': 'script',
             'stack': {
                 'callFrames': [],
                 'parent': {
                     'callFrames': [{
                         'url': 'http://bla.com/nyancat.js'
                     }]
                 }
             }
         },
         'timestamp':
         10,
         'timing':
         TimingFromDict({})
     })
     loading_trace = test_utils.LoadingTraceFromEvents(
         [TestRequests.JS_REQUEST, JS_REQUEST_WITH_ASYNC_STACK])
     request_dependencies_lens = RequestDependencyLens(loading_trace)
     deps = request_dependencies_lens.GetRequestDependencies()
     self.assertEquals(1, len(deps))
     self._AssertDependencyIs(deps[0], TestRequests.JS_REQUEST.request_id,
                              JS_REQUEST_WITH_ASYNC_STACK.request_id,
                              'script')
Example #2
0
 def testParserDependency(self):
     loading_trace = test_utils.LoadingTraceFromEvents(
         [TestRequests.REQUEST, TestRequests.JS_REQUEST])
     request_dependencies_lens = RequestDependencyLens(loading_trace)
     deps = request_dependencies_lens.GetRequestDependencies()
     self.assertEquals(1, len(deps))
     self._AssertDependencyIs(deps[0], TestRequests.REQUEST.request_id,
                              TestRequests.JS_REQUEST.request_id, 'parser')
Example #3
0
 def testScriptDependency(self):
     loading_trace = test_utils.LoadingTraceFromEvents(
         [self._JS_REQUEST, self._JS_REQUEST_2])
     request_dependencies_lens = RequestDependencyLens(loading_trace)
     deps = request_dependencies_lens.GetRequestDependencies()
     self.assertEquals(1, len(deps))
     self._AssertDependencyIs(deps[0], self._JS_REQUEST.request_id,
                              self._JS_REQUEST_2.request_id, 'script')
Example #4
0
 def testDependencyDifferentFrame(self):
     """Checks that a more recent request from another frame is ignored."""
     loading_trace = test_utils.LoadingTraceFromEvents([
         self._JS_REQUEST, self._JS_REQUEST_OTHER_FRAME, self._JS_REQUEST_2
     ])
     request_dependencies_lens = RequestDependencyLens(loading_trace)
     deps = request_dependencies_lens.GetRequestDependencies()
     self.assertEquals(1, len(deps))
     self._AssertDependencyIs(deps[0], self._JS_REQUEST.request_id,
                              self._JS_REQUEST_2.request_id, 'script')
Example #5
0
 def testRedirectDependency(self):
     loading_trace = test_utils.LoadingTraceFromEvents(
         [self._REDIRECT_REQUEST, self._REDIRECTED_REQUEST])
     request_dependencies_lens = RequestDependencyLens(loading_trace)
     deps = request_dependencies_lens.GetRequestDependencies()
     self.assertEquals(1, len(deps))
     (first, second, reason) = deps[0]
     self.assertEquals('redirect', reason)
     self.assertEquals(self._REDIRECT_REQUEST.request_id, first.request_id)
     self.assertEquals(self._REQUEST.request_id, second.request_id)
Example #6
0
 def testDependencySameParentFrame(self):
     """Checks that a more recent request from an unrelated frame is ignored
 if there is one from a related frame."""
     loading_trace = test_utils.LoadingTraceFromEvents([
         TestRequests.JS_REQUEST_OTHER_FRAME,
         TestRequests.JS_REQUEST_UNRELATED_FRAME, TestRequests.JS_REQUEST_2
     ], TestRequests.PAGE_EVENTS)
     request_dependencies_lens = RequestDependencyLens(loading_trace)
     deps = request_dependencies_lens.GetRequestDependencies()
     self.assertEquals(1, len(deps))
     self._AssertDependencyIs(
         deps[0], TestRequests.JS_REQUEST_OTHER_FRAME.request_id,
         TestRequests.JS_REQUEST_2.request_id, 'script')
Example #7
0
 def testSeveralDependencies(self):
     loading_trace = test_utils.LoadingTraceFromEvents([
         self._REDIRECT_REQUEST, self._REDIRECTED_REQUEST, self._JS_REQUEST,
         self._JS_REQUEST_2
     ])
     request_dependencies_lens = RequestDependencyLens(loading_trace)
     deps = request_dependencies_lens.GetRequestDependencies()
     self.assertEquals(3, len(deps))
     self._AssertDependencyIs(deps[0], self._REDIRECT_REQUEST.request_id,
                              self._REQUEST.request_id, 'redirect')
     self._AssertDependencyIs(deps[1], self._REQUEST.request_id,
                              self._JS_REQUEST.request_id, 'parser')
     self._AssertDependencyIs(deps[2], self._JS_REQUEST.request_id,
                              self._JS_REQUEST_2.request_id, 'script')