Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing document.hasFocus method, needs tests. #6475 #6757

Merged
merged 1 commit into from Aug 11, 2015
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Implementing document.hasFocus method. #6475

  • Loading branch information
Maciej Skrzypkowski
Maciej Skrzypkowski committed Aug 10, 2015
commit 07c0cd8a18dd7421a1670829106d40e2037c1b8c
@@ -1183,6 +1183,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()
@@ -114,7 +114,7 @@ partial /*sealed*/ interface Document {
// user interaction
readonly attribute Window/*Proxy?*/ defaultView;
// readonly attribute Element? activeElement;
// boolean hasFocus();
boolean hasFocus();
// attribute DOMString designMode;
// boolean execCommand(DOMString commandId, optional boolean showUI = false, optional DOMString value = "");
// boolean queryCommandEnabled(DOMString commandId);
@@ -30,9 +30,6 @@
[Document interface: operation writeln(DOMString)]
expected: FAIL

[Document interface: operation hasFocus()]
expected: FAIL

[Document interface: attribute designMode]
expected: FAIL

@@ -1098,9 +1095,6 @@
[Document interface: calling writeln(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError]
expected: FAIL

[Document interface: document.implementation.createDocument(null, "", null) must inherit property "hasFocus" with the proper type (61)]
expected: FAIL

[Document interface: document.implementation.createDocument(null, "", null) must inherit property "designMode" with the proper type (62)]
expected: FAIL

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.