Development

Changeset 4287

You must first sign up to be able to contribute.

Changeset 4287

Show
Ignore:
Timestamp:
06/20/07 14:08:19 (1 year ago)
Author:
fabien
Message:

fixed sfBrowser keeps previous Dom is response is not XHTML (closes #1853)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/util/sfBrowser.class.php

    r3334 r4287  
    208208      $this->domCssSelector = new sfDomCssSelector($this->dom); 
    209209    } 
     210    else 
     211    { 
     212      $this->dom = null; 
     213      $this->domCssSelector = null; 
     214    } 
    210215 
    211216    return $this; 
     
    246251  public function getResponseDomCssSelector() 
    247252  { 
     253    if (is_null($this->dom)) 
     254    { 
     255      throw new sfException('The DOM is not accessible because the browser response content type is not HMTL.'); 
     256    } 
     257 
    248258    return $this->domCssSelector; 
    249259  } 
     
    251261  public function getResponseDom() 
    252262  { 
     263    if (is_null($this->dom)) 
     264    { 
     265      throw new sfException('The DOM is not accessible because the browser response content type is not HMTL.'); 
     266    } 
     267 
    253268    return $this->dom; 
    254269  } 
     
    295310  public function click($name, $arguments = array()) 
    296311  { 
    297     if (!$this->dom) 
     312    $dom = $this->getResponseDom(); 
     313 
     314    if (!$dom) 
    298315    { 
    299316      throw new sfException('Cannot click because there is no current page in the browser'); 
    300317    } 
    301318 
    302     $xpath = new DomXpath($this->dom); 
    303     $dom   = $this->dom; 
     319    $xpath = new DomXpath($dom); 
    304320 
    305321    // text link 
  • trunk/test/functional/sfTestBrowserTest.php

    r2980 r4287  
    4242  throwsException('sfException', 'sfException message') 
    4343; 
     44 
     45$b-> 
     46  get('/browser')-> 
     47  responseContains('html')-> 
     48  checkResponseElement('h1', 'html')-> 
     49 
     50  get('/browser/text')-> 
     51  responseContains('text') 
     52; 
     53 
     54try 
     55{ 
     56  $b->checkResponseElement('h1', 'text'); 
     57  $b->test()->fail('The DOM is not accessible if the response content type is not HTML'); 
     58} 
     59catch (sfException $e) 
     60{ 
     61  $b->test()->pass('The DOM is not accessible if the response content type is not HTML'); 
     62}