forked from bluesmoon/boomerang
-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AutoXHR: if we don't instrument xhr open then don't instrument send e…
…ither
- Loading branch information
1 parent
f66eb82
commit 58b0879
Showing
4 changed files
with
114 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
tests/page-templates/05-angular/116-autoxhr-xhrexcludes.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!-- | ||
Issue 662 | ||
Test that xhrs excluded from instrumentation don't cause SPA to wait indefinitely | ||
--> | ||
<%= header %> | ||
<%= boomerangScript %> | ||
<base href="/pages/05-angular/" /> | ||
<script src="../../vendor/angular/angular.js"></script> | ||
<script src="../../vendor/angular-resource/angular-resource.js"></script> | ||
<script src="../../vendor/angular-route/angular-route.js"></script> | ||
<script> | ||
window.angular_imgs = [3000]; | ||
|
||
window.angular_html5_mode = false; | ||
|
||
// view a widget then come back so debugging (F5) is easier | ||
window.angular_nav_routes = ["/widgets/1", "/"]; | ||
|
||
window.BOOMR = window.BOOMR || {}; | ||
window.BOOMR.xhr_excludes = { | ||
"/pages/05-angular/support/img.jpg": true | ||
}; | ||
</script> | ||
<script src="support/app.js"></script> | ||
<div ng-app="app"> | ||
<div ng-view> | ||
</div> | ||
</div> | ||
<script src="116-autoxhr-xhrexcludes.js" type="text/javascript"></script> | ||
<script> | ||
BOOMR.subscribe("spa_init", function() { | ||
// send an xhr during a spa navigation | ||
setTimeout(function() { | ||
// this xhr should match the exclude filter | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open("GET", "/pages/05-angular/support/img.jpg?rnd=" + Math.random()); | ||
xhr.send(null); | ||
}, 100); | ||
}); | ||
BOOMR_test.init({ | ||
testAfterOnBeacon: 3, | ||
Angular: { | ||
enabled: true | ||
}, | ||
instrument_xhr: true, | ||
autorun: false | ||
}); | ||
|
||
// Timeout after 30s in case auto xhr is still waiting for a resource | ||
window.timerid = setTimeout(function() { | ||
BOOMR_test.runTests(); | ||
}, 30000); | ||
|
||
</script> | ||
<%= footer %> |
36 changes: 36 additions & 0 deletions
36
tests/page-templates/05-angular/116-autoxhr-xhrexcludes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/*eslint-env mocha*/ | ||
/*global BOOMR,BOOMR_test,describe,it*/ | ||
|
||
describe("e2e/05-angular/116-autoxhr-xhrexcludes.js", function() { | ||
var tf = BOOMR.plugins.TestFramework; | ||
var t = BOOMR_test; | ||
|
||
it("Should pass basic beacon validation", function(done) { | ||
t.validateBeaconWasSent(done); | ||
clearTimeout(window.timerid); | ||
}); | ||
|
||
it("Should have sent three beacons", function() { | ||
assert.equal(tf.beacons.length, 3); | ||
}); | ||
|
||
it("Should have sent the first beacon as http.initiator = spa_hard", function() { | ||
assert.equal(tf.beacons[0]["http.initiator"], "spa_hard"); | ||
}); | ||
|
||
it("Should have beacon 1 as a spa_hard", function() { | ||
var b = tf.beacons[0]; | ||
assert.equal(b["http.initiator"], "spa_hard"); | ||
}); | ||
|
||
it("Should have beacon 2 as a spa", function() { | ||
var b = tf.beacons[1]; | ||
assert.equal(b["http.initiator"], "spa"); | ||
}); | ||
|
||
it("Should have beacon 3 as a spa", function() { | ||
var b = tf.beacons[2]; | ||
assert.equal(b["http.initiator"], "spa"); | ||
}); | ||
}); | ||
|