forked from jeresig/env-js
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented 'iframe.src = "new-url"' causing an actual document load.
Added matching tests, broke (i)frame-specific tests into a separate file from the generic-window tests.
- Loading branch information
Showing
7 changed files
with
133 additions
and
16 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" | ||
lang="en" dir="ltr" id="html"> | ||
<head> | ||
<title>Content document for IFRAME loading in env.js unit test suite</title> | ||
</head> | ||
<body> | ||
<p id="aParaInAnIframe"> | ||
Here is a short paragraph. | ||
</p> | ||
</body> | ||
</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
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,50 @@ | ||
/* | ||
* This file is a component of env.js, | ||
* http://github.com/gleneivey/env-js/commits/master/README | ||
* a Pure JavaScript Browser Environment | ||
* Copyright 2009 John Resig, licensed under the MIT License | ||
* http://www.opensource.org/licenses/mit-license.php | ||
*/ | ||
|
||
|
||
module("frame"); | ||
|
||
|
||
// all tests to next comment rely on content of ../html/iframe.html | ||
test("IFRAMEs load with accessible content", function() { | ||
expect(3); | ||
|
||
var iframe = document.getElementById('loadediframe'); | ||
try{ok (iframe.src == "html/iframe.html", | ||
"Initial iframe src matches test page source"); | ||
}catch(e){print(e);} | ||
|
||
var idoc = iframe.contentDocument; | ||
var mtch = idoc.title.match(/IFRAME/); | ||
try{ok (mtch && mtch.length > 0, | ||
"Can get 'document' object from test iframe"); | ||
}catch(e){print(e);} | ||
|
||
var para = idoc.getElementById('anElementWithText'); | ||
mtch = para.innerHTML.match(/content of a paragraph/); | ||
try{ok (mtch && mtch.length > 0, | ||
"Can get text from element in an iframe"); | ||
}catch(e){print(e);} | ||
}); | ||
|
||
// all tests to next comment rely on content of ../html/iframe2.html | ||
test("IFRAMEs reload on assignment to 'src'", function() { | ||
expect(2); | ||
|
||
var iframe = document.getElementById('loadediframe'); | ||
iframe.src = "html/iframe2.html"; | ||
try{ok (iframe.src == "html/iframe2.html", | ||
"iframe.src matches value assigned"); | ||
}catch(e){print(e);} | ||
|
||
var para = iframe.contentDocument.getElementById('aParaInAnIframe'); | ||
mtch = para.innerHTML.match(/short paragraph/); | ||
try{ok (mtch && mtch.length > 0, | ||
"IFRAME reloaded from correct source"); | ||
}catch(e){print(e);} | ||
}); |
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