location-bar
Version:
A microlib for managing browser's location bar via pushState and hashChange APIs. This lib makes it easy to listen to URL changes and update the URL.
62 lines (51 loc) • 1.88 kB
HTML
<html>
<head>
<meta charset='utf8'>
<title>Backbone.Router test suite</title>
<link rel="stylesheet" href="vendor/qunit.css" type="text/css" media="screen">
</head>
<body>
<div id="qunit"></div>
<script src="vendor/json2.js"></script>
<script src="vendor/jquery.js"></script>
<script src="vendor/qunit.js"></script>
<script src="vendor/underscore.js"></script>
<!-- a slightly modified version of backbone -->
<script src="backbone/backbone.js"></script>
<script>
// because these Backbone tests aren't setup to use AMD,
// let's fake the amd
var define = function (f) {
window.LocationBar = f();
}
define.amd = true;
</script>
<script>
var BackboneRouter = Backbone.Router;
var BackboneEvents = Backbone.Events;
var RealBackbone = Backbone.noConflict();
</script>
<script src="../location-bar.js"></script>
<script>
// we include the entire Backbone to be able to run the entire test suite
// of Backbone.Router, but with this extracted version of Backbone.History
// here we delete Backbone from window to avoid using it in history module/tests
// in uncontrolled ways
// to be able to run original Backbone tests, we need to (re)create
// the Backbone object on window, but we'll swap out the History implementation
// with the LocationBar module.
// we need to mix in events into History, because Backbone.Router
// is triggering them on Backbone.history
_.extend(window.LocationBar.prototype, BackboneEvents);
window.Backbone = {
Router: RealBackbone.Router,
History: window.LocationBar,
history: new window.LocationBar()
};
// We never want to actually call these during tests.
history.pushState = history.replaceState = function(){};
</script>
<script src="backbone_router_test.js"></script>
</body>
</html>