Source for file frames.php
Documentation is available at frames.php
* Base include file for SimpleTest
* @version $Id: frames.php 1672 2008-03-02 04:47:34Z edwardzyang $
* include other SimpleTest class files
require_once(dirname(__FILE__
) .
'/page.php');
require_once(dirname(__FILE__
) .
'/user_agent.php');
* A composite page. Wraps a frameset page and
* adds subframes. The original page will be
* mostly ignored. Implements the SimplePage
* interface so as to be interchangeable.
* Stashes the frameset page. Will make use of the
* browser to fetch the sub frames recursively.
* @param SimplePage $page Frameset page.
* Adds a parsed page to the frameset.
* @param SimplePage $page Frame page.
* @param string $name Name of frame in frameset.
function addFrame(&$page, $name =
false) {
* Replaces existing frame with another. If the
* frame is nested, then the call is passed down
* @param array $path Path of frame in frameset.
* @param SimplePage $page Frame source.
if (isset
($this->_names[$name])) {
$index =
$this->_names[$name];
$this->_frames[$index]->setFrame($path, $page);
* Accessor for current frame focus. Will be
* false if no frame has focus. Will have the nested
* @return array Labels or indexes of nested frames.
if ($this->_focus ===
false) {
array($this->_getPublicNameFromIndex($this->_focus)),
* Turns an internal array index into the frames list
* into a public name, or if none, then a one offset
* @param integer $subject Internal index.
* @return integer/string Public name.
function _getPublicNameFromIndex($subject) {
foreach ($this->_names as $name =>
$index) {
if ($subject ==
$index) {
* Sets the focus by index. The integer index starts from 1.
* If already focused and the target frame also has frames,
* then the nested frame will be focused.
* @param integer $choice Chosen frame.
* @return boolean True if frame exists.
return $this->_frames[$this->_focus]->setFrameFocusByIndex($choice);
* Sets the focus by name. If already focused and the
* target frame also has frames, then the nested frame
* @param string $name Chosen frame.
* @return boolean True if frame exists.
* Clears the frame focus.
$this->_clearNestedFramesFocus();
* Clears the frame focus for any nested frames.
function _clearNestedFramesFocus() {
$this->_frames[$i]->clearFrameFocus();
* Test for the presence of a frameset.
* @return boolean Always true.
* Accessor for frames information.
* @return array/string Recursive hash of frame URL strings.
* The key is either a numerical
* index or the name attribute.
$report[$this->_getPublicNameFromIndex($i)] =
* Accessor for raw text of either all the pages or
* @return string Raw unparsed content.
$raw .=
$this->_frames[$i]->getRaw();
* Accessor for plain text of either all the pages or
* @return string Plain text content.
$raw .=
' ' .
$this->_frames[$i]->getText();
* Accessor for last error.
* @return string Error from last response.
return $this->_frameset->getTransportError();
* Request method used to fetch this frame.
* @return string GET, POST or HEAD.
* Original resource name.
* @return SimpleUrl Current url.
$url->setTarget($this->_getPublicNameFromIndex($this->_focus));
* @return SimpleUrl Current url.
* Expands expandomatic URLs into fully qualified
* URLs for the frameset page.
* @param SimpleUrl $url Relative URL.
* @return SimpleUrl Absolute URL.
* @return mixed Sent content.
* Accessor for current MIME type.
* @return string MIME type as string; e.g. 'text/html'
* Accessor for last response code.
* @return integer Last HTTP response code received.
* Accessor for last Authentication type. Only valid
* straight after a challenge (401).
* @return string Description of challenge type.
return $this->_frameset->getAuthentication();
* Accessor for last Authentication realm. Only valid
* straight after a challenge (401).
* @return string Name of security realm.
* Accessor for outgoing header information.
* @return string Header block.
* Accessor for raw header information.
* @return string Header block.
* Accessor for parsed title.
* @return string Title or false if no title is present.
* Accessor for a list of all fixed links.
* @return array List of urls as strings.
foreach ($this->_frames as $frame) {
* Accessor for URLs by the link label. Label will match
* regardess of whitespace issues and case.
* @param string $label Text of link.
* @return array List of links with that label.
return $this->_tagUrlsWithFrame(
foreach ($this->_frames as $index =>
$frame) {
$this->_tagUrlsWithFrame(
$frame->getUrlsByLabel($label),
* Accessor for a URL by the id attribute. If in a frameset
* then the first link found with that ID attribute is
* returned only. Focus on a frame if you want one from
* a specific part of the frameset.
* @param string $id Id attribute of link.
* @return string URL with that id.
foreach ($this->_frames as $index =>
$frame) {
if ($url =
$frame->getUrlById($id)) {
if (! $url->gettarget()) {
$url->setTarget($this->_getPublicNameFromIndex($index));
* Attaches the intended frame index to a list of URLs.
* @param array $urls List of SimpleUrls.
* @param string $frame Name of frame or index.
* @return array List of tagged URLs.
function _tagUrlsWithFrame($urls, $frame) {
foreach ($urls as $url) {
if (! $url->getTarget()) {
$url->setTarget($this->_getPublicNameFromIndex($frame));
* Finds a held form by button label. Will only
* search correctly built forms.
* @param SimpleSelector $selector Button finder.
* @return SimpleForm Form object containing
$form =
&$this->_findForm('getFormBySubmit', $selector);
* Finds a held form by image using a selector.
* Will only search correctly built forms. The first
* form found either within the focused frame, or
* across frames, will be the one returned.
* @param SimpleSelector $selector Image finder.
* @return SimpleForm Form object containing
$form =
&$this->_findForm('getFormByImage', $selector);
* Finds a held form by the form ID. A way of
* identifying a specific form when we have control
* of the HTML code. The first form found
* either within the focused frame, or across frames,
* will be the one returned.
* @param string $id Form label.
* @return SimpleForm Form object containing the matching ID.
$form =
&$this->_findForm('getFormById', $id);
* General form finder. Will search all the frames or
* @param string $method Method to use to find in a page.
* @param string $attribute Label, name or ID.
* @return SimpleForm Form object containing the matching ID.
function &_findForm($method, $attribute) {
$form =
&$this->_findFormInFrame(
$form =
&$this->_findFormInFrame(
* Finds a form in a page using a form finding method. Will
* also tag the form with the frame name it belongs in.
* @param SimplePage $page Page content of frame.
* @param integer $index Internal frame representation.
* @param string $method Method to use to find in a page.
* @param string $attribute Label, name or ID.
* @return SimpleForm Form object containing the matching ID.
function &_findFormInFrame(&$page, $index, $method, $attribute) {
$form =
&$this->_frames[$index]->$method($attribute);
$form->setDefaultTarget($this->_getPublicNameFromIndex($index));
* Sets a field on each form in which the field is
* @param SimpleSelector $selector Field finder.
* @param string $value Value to set field to.
* @return boolean True if value is valid.
$this->_frames[$i]->setField($selector, $value);
* Accessor for a form element value within a page.
* @param SimpleSelector $selector Field finder.
* @return string/boolean A string if the field is
* present, false if unchecked
$value =
$this->_frames[$i]->getField($selector);
Documentation generated on Sun, 04 May 2008 09:21:39 -0500 by phpDocumentor 1.3.0