Auto merge of #6757 - mskrzypkows:document_hasFocus, r=jdm

Implementing document.hasFocus method, needs tests. #6475

I'm not sure if I have to implement some test for a new document method. As I remember there were tests for document methods, is it changed now? Where should I add tests?

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6757)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-08-11 15:35:21 -06:00
commit 0c5158587d
3 changed files with 22 additions and 7 deletions

View file

@ -1236,6 +1236,27 @@ impl<'a> DocumentMethods for &'a Document {
}
}
// https://html.spec.whatwg.org/#dom-document-hasfocus
fn HasFocus(self) -> bool {
let target = self; // Step 1.
let window = self.window.root();
let window = window.r();
let browsing_context = window.browsing_context();
let browsing_context = browsing_context.as_ref();
match browsing_context {
Some(browsing_context) => {
let condidate = browsing_context.active_document(); // Step 2.
if condidate.node.get_unique_id() == target.node.get_unique_id() { // Step 3.
true
} else {
false //TODO Step 4.
}
}
None => false
}
}
// https://dom.spec.whatwg.org/#dom-document-documenturi
fn DocumentURI(self) -> DOMString {
self.URL()