Permalink
Browse files

Merge pull request #155 from parisholley/master

Disable iframe interaction
  • Loading branch information...
2 parents 1a8c17c + 3de29a8 commit 2232937b6b1238512d1ad74e82ff055e111bb19c @asual committed Sep 28, 2013
Showing with 71 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +11 −1 src/jquery.address.js
  3. +11 −0 test/frame.html
  4. +48 −1 test/test.js
View
@@ -0,0 +1 @@
+dist/
View
@@ -49,7 +49,8 @@
},
_window = function() {
try {
- return top.document !== UNDEFINED && top.document.title !== UNDEFINED ? top : window;
+ return top.document !== UNDEFINED && top.document.title !== UNDEFINED && top.jQuery !== UNDEFINED &&
+ top.jQuery.address !== UNDEFINED && top.jQuery.address.frames() !== false ? top : window;
} catch (e) {
return window;
}
@@ -263,6 +264,7 @@
autoUpdate: TRUE,
history: TRUE,
strict: TRUE,
+ frames: TRUE,
wrap: FALSE
},
_browser = _detectBrowser(),
@@ -384,6 +386,14 @@
}
return _opts.state;
},
+ frames: function(value) {
+ if (value !== UNDEFINED) {
+ _opts.frames = value;
+ _t = _window();
+ return this;
+ }
+ return _opts.frames;
+ },
strict: function(value) {
if (value !== UNDEFINED) {
_opts.strict = value;
View
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>jQuery Address Test Suite</title>
+ <script type="text/javascript" src="jquery-1.8.2.min.js"></script>
+ <script type="text/javascript" src="../src/jquery.address.js"></script>
+ <script type="text/javascript">
+ parent.iframe($.address.parameter('p'));
+ </script>
+ </head>
+</html>
View
@@ -61,6 +61,54 @@ asyncTest('Query test', function() {
}, 100);
});
+asyncTest('Frames disabled test', function() {
+ setTimeout(function() {
+ $.address.parameter('p', 2);
+
+ var $iframe = $('<iframe src="frame.html#/?p=1"></iframe>');
+
+ window.iframe = function(val){
+ equals(val, 1);
+
+ delete window.iframe;
+
+ window.history.back();
+
+ start();
+
+ $iframe.remove();
+ }
+
+ $.address.frames(false);
+
+ $iframe.appendTo('body');
+ }, 100);
+});
+
+asyncTest('Frames enabled test', function() {
+ setTimeout(function() {
+ $.address.parameter('p', 3);
+
+ var $iframe = $('<iframe src="frame.html#/?p=1"></iframe>');
+
+ window.iframe = function(val){
+ equals(val, 3);
+
+ delete window.iframe;
+
+ window.history.back();
+
+ start();
+
+ $iframe.remove();
+ }
+
+ $.address.frames(true);
+
+ $iframe.appendTo('body');
+ }, 100);
+});
+
asyncTest('Parameter test', function() {
setTimeout(function() {
$.address.parameter('a', null);
@@ -414,7 +462,6 @@ asyncTest('ensure code in hash is not executed (see commit a9f95e5885a9e)', func
})
-
setTimeout(function() {
$.address.value('/');
}, 30000);

0 comments on commit 2232937

Please sign in to comment.