| <!DOCTYPE html> | |
| <!-- | |
| Copyright 2011 WebDriver committers | |
| Copyright 2011 Google Inc. | |
| Licensed under the Apache License, Version 2.0 (the "License"); | |
| you may not use this file except in compliance with the License. | |
| You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software | |
| distributed under the License is distributed on an "AS IS" BASIS, | |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| See the License for the specific language governing permissions and | |
| limitations under the License. | |
| --> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>frame_test.html</title> | |
| <link rel="stylesheet" href="/filez/_main/third_party/js/qunit/qunit.css"> | |
| <script src="/filez/_main/third_party/js/qunit/qunit.js"></script> | |
| <script src="/filez/_main/third_party/js/qunit/qunit_test_runner.js"></script> | |
| <script src="test_bootstrap.js" type="text/javascript"></script> | |
| <script type="text/javascript"> | |
| goog.require('bot'); | |
| goog.require('bot.frame'); | |
| goog.require('goog.userAgent'); | |
| </script> | |
| <script type="text/javascript"> | |
| QUnit.test('FindFrameByName', function(assert) { | |
| var first = bot.frame.findFrameByNameOrId("first"); | |
| assert.strictEqual(first, window.frames[0]); | |
| }); | |
| QUnit.test('FindNestedFrameByNameFromTopWindowReturnsNull', function(assert) { | |
| var nested = bot.frame.findFrameByNameOrId("first.withadot"); | |
| assert.strictEqual(nested, null); | |
| }); | |
| QUnit.test('FindFrameByNameShouldReturnNullIfFrameDoesNotExists', function(assert) { | |
| var notThere = bot.frame.findFrameByNameOrId("notThere"); | |
| assert.strictEqual(notThere, null); | |
| }); | |
| QUnit.test('FindNestedFrameByName', function(assert) { | |
| var frame = document.getElementById("embedded"); | |
| var nested = bot.frame.findFrameByNameOrId("secondName", bot.frame.getFrameWindow(frame)); | |
| assert.strictEqual(nested, window.frames[2].frames[1]); | |
| }); | |
| QUnit.test('FindParentFrameReturnsNull', function(assert) { | |
| var frame = document.getElementById("embedded"); | |
| var parent = bot.frame.findFrameByNameOrId("firstName", bot.frame.getFrameWindow(frame)); | |
| assert.strictEqual(parent, null); | |
| }); | |
| QUnit.test('FindFrameById', function(assert) { | |
| var second = bot.frame.findFrameByNameOrId("second"); | |
| assert.strictEqual(second, window.frames[1]); | |
| }); | |
| QUnit.test('FindNestedFrameByIdFailsToFindNestedFrames', function(assert) { | |
| var nested = bot.frame.findFrameByNameOrId("embed1.withadot"); | |
| assert.strictEqual(nested, null); | |
| }); | |
| QUnit.test('FindFrameDoesNotFindParentFrames', function(assert) { | |
| var embedded = window.frames[2]; | |
| var nested = bot.frame.findFrameByNameOrId("first", embedded); | |
| assert.strictEqual(nested, null); | |
| }); | |
| QUnit.test('FindNestedFrameById', function(assert) { | |
| var embedded = window.frames[2]; | |
| var nested = bot.frame.findFrameByNameOrId("second", embedded); | |
| assert.strictEqual(nested, embedded.frames[1]); | |
| }); | |
| QUnit.test('FindFrameByIdReturnsNull', function(assert) { | |
| var notThere = bot.frame.findFrameByNameOrId("notThere"); | |
| assert.strictEqual(notThere, null); | |
| }); | |
| QUnit.test('FindFrameByIndex', function(assert) { | |
| var second = bot.frame.findFrameByIndex(1); | |
| assert.strictEqual(second, window.frames[1]); | |
| var nested = bot.frame.findFrameByIndex(1, window.frames[2]); | |
| assert.strictEqual(nested, window.frames[2].frames[1]); | |
| }); | |
| QUnit.test('FindFrameByIndexReturnsNull', function(assert) { | |
| var notThere = bot.frame.findFrameByIndex(4); | |
| assert.strictEqual(notThere, null); | |
| }); | |
| QUnit.test('FindIFrameByName', function(assert) { | |
| var iframe = bot.frame.findFrameByNameOrId("iframename1", window.frames[1]); | |
| assert.strictEqual(iframe, window.frames[1].frames[0]); | |
| }); | |
| QUnit.test('FindNestedIFrameByNameFromTopWindowReturnsNull', function(assert) { | |
| var iframe = bot.frame.findFrameByNameOrId("iframename1"); | |
| assert.strictEqual(iframe, null); | |
| }); | |
| QUnit.test('FindNestedIFrameByName', function(assert) { | |
| var nested = bot.frame.findFrameByNameOrId("iframename1", window.frames[1].frames[1]); | |
| assert.strictEqual(nested, window.frames[1].frames[1].frames[0]); | |
| }); | |
| QUnit.test('FindIFrameByNameDoesNotFindParentFrame', function(assert) { | |
| var parent = bot.frame.findFrameByNameOrId("iframename2", window.frames[1].frames[1].frames[0]); | |
| assert.strictEqual(parent, null); | |
| }); | |
| QUnit.test('FindIFrameById', function(assert) { | |
| var second = bot.frame.findFrameByNameOrId("iframe2", window.frames[1]); | |
| assert.strictEqual(second, window.frames[1].frames[1]); | |
| }); | |
| QUnit.test('FindNestedIFrameByIdFailsToFindNestedFrames', function(assert) { | |
| var nested = bot.frame.findFrameByNameOrId("iframe1"); | |
| assert.strictEqual(nested, null); | |
| }); | |
| QUnit.test('FindIFrameByIdDoesNotFindParentFrame', function(assert) { | |
| var nested = bot.frame.findFrameByNameOrId("iframe2", window.frames[1].frames[1].frames[0]); | |
| assert.strictEqual(nested, null); | |
| }); | |
| QUnit.test('FindIFrameByIdReturnsNull', function(assert) { | |
| var notThere = bot.frame.findFrameByNameOrId("notThere"); | |
| assert.strictEqual(notThere, null); | |
| }); | |
| QUnit.test('GetFrameIndex', function(assert) { | |
| var el = document.getElementById("second"); | |
| var index = bot.frame.getFrameIndex(el); | |
| assert.strictEqual(index, 1); | |
| el = document.getElementById("embedded"); | |
| index = bot.frame.getFrameIndex(el); | |
| assert.strictEqual(index, 2); | |
| }); | |
| QUnit.test('GetFrameIndexNotFrame', function(assert) { | |
| var el = document.body; | |
| var index = bot.frame.getFrameIndex(el); | |
| assert.strictEqual(index, null); | |
| }); | |
| QUnit.test('GetFrameIndexNotAttached', function(assert) { | |
| var el = document.createElement("frame"); | |
| var index = bot.frame.getFrameIndex(el); | |
| assert.strictEqual(index, null); | |
| }); | |
| QUnit.test('GetFrameIndexDifferentWindow', function(assert) { | |
| var frameWin = document.getElementById("second").contentWindow; | |
| var el = frameWin.document.getElementById("iframe2"); | |
| var index = bot.frame.getFrameIndex(el, frameWin); | |
| assert.strictEqual(index, 1); | |
| }); | |
| QUnit.test('FindParentFrame', function(assert) { | |
| if (goog.userAgent.IE && !bot.userAgent.isProductVersion(9)) { | |
| assert.ok(true, 'Skipping: IE < 9 does not see window objects as equal'); | |
| return; | |
| } | |
| var frameWin = bot.frame.parentFrame(window.frames[1]); | |
| assert.strictEqual(frameWin, window); | |
| }); | |
| QUnit.test('ParentFrameOnTopLevelIsNoOp', function(assert) { | |
| if (goog.userAgent.IE && !bot.userAgent.isProductVersion(9)) { | |
| assert.ok(true, 'Skipping: IE < 9 does not see window objects as equal'); | |
| return; | |
| } | |
| var frameWin = bot.frame.parentFrame(window); | |
| assert.strictEqual(frameWin, window); | |
| }); | |
| </script> | |
| </head> | |
| <frameset rows="*,*,*" > | |
| <frame name="firstName" id="first" style="display:none;"> | |
| <html> | |
| <head> | |
| <title>first frame</title> | |
| </head> | |
| <body> | |
| <div name="right" id="bou" class="dogs">yup</div> | |
| </body> | |
| </html> | |
| </frame> | |
| <frame id="second" name="secondName" src="testdata/nested_iframes.html"> | |
| </frame> | |
| <frame id="embedded" src="testdata/nested_frames.html"> | |
| </frame> | |
| </frameset> | |
| </html> |