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

Make Document::DefaultView return a null value when there's no browsing context #11548

Merged
merged 1 commit into from Jun 9, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Make Document::DefaultView return a null value when there's no browsi…

…ng context
  • Loading branch information
kevgs committed Jun 8, 2016
commit 3bb093cc16875c6fcfe5e7de9c9f6760ff9e18fc
@@ -2551,8 +2551,12 @@ impl DocumentMethods for Document {
}

// https://html.spec.whatwg.org/multipage/#dom-document-defaultview
fn DefaultView(&self) -> Root<Window> {
Root::from_ref(&*self.window)
fn GetDefaultView(&self) -> Option<Root<Window>> {
if self.browsing_context.is_none() {
None
} else {
Some(Root::from_ref(&*self.window))
}
}

// https://html.spec.whatwg.org/multipage/#dom-document-cookie
@@ -1297,7 +1297,10 @@ impl Element {
}

// Step 5
let win = doc.DefaultView();
let win = match doc.GetDefaultView() {
None => return,
Some(win) => win,
};

// Step 7
if *self.root_element() == *self {
@@ -1635,7 +1638,10 @@ impl ElementMethods for Element {
}

// Step 3
let win = doc.DefaultView();
let win = match doc.GetDefaultView() {
None => return 0.0,
Some(win) => win,
};

// Step 5
if *self.root_element() == *self {
@@ -1683,7 +1689,10 @@ impl ElementMethods for Element {
}

// Step 5
let win = doc.DefaultView();
let win = match doc.GetDefaultView() {
None => return,
Some(win) => win,
};

// Step 7
if *self.root_element() == *self {
@@ -1721,7 +1730,10 @@ impl ElementMethods for Element {
}

// Step 3
let win = doc.DefaultView();
let win = match doc.GetDefaultView() {
None => return 0.0,
Some(win) => win,
};

// Step 5
if *self.root_element() == *self {
@@ -1769,7 +1781,10 @@ impl ElementMethods for Element {
}

// Step 5
let win = doc.DefaultView();
let win = match doc.GetDefaultView() {
None => return,
Some(win) => win,
};

// Step 7
if *self.root_element() == *self {
@@ -118,7 +118,7 @@ partial /*sealed*/ interface Document {
// void writeln(DOMString... text);

// user interaction
readonly attribute Window/*Proxy?*/ defaultView;
readonly attribute Window?/*Proxy?*/ defaultView;

This comment has been minimized.

@KiChjang

KiChjang Jun 8, 2016

Member

Why are you changing this?

This comment has been minimized.

@kevgs

kevgs Jun 8, 2016

Author Contributor

It was required here #11469

readonly attribute Element? activeElement;
boolean hasFocus();
// attribute DOMString designMode;
"deleted_reftests": {},
"items": {
"testharness": {
"cssom-view/scrolling-no-browsing-context.html": [
{
"path": "cssom-view/scrolling-no-browsing-context.html",
"url": "/cssom-view/scrolling-no-browsing-context.html"
}
],
"url/url-domainToUnicode.html": [
{
"path": "url/url-domainToUnicode.html",
@@ -9,9 +9,6 @@
[readyState]
expected: FAIL

[defaultView]
expected: FAIL

[body]
expected: FAIL

This file was deleted.

@@ -0,0 +1,33 @@
<!doctype html>
<meta charset="utf-8">
<title>cssom-view scrolling-no-browsing-context</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({explicit_done:true});
window.onload = function () {
test(function () {
var doc = document.implementation.createDocument("http://example.com/", "html", null);

var element = doc.createElement("tag")
assert_equals(element.scrollTop, 0, "scrollTop should be always 0");
assert_equals(element.scrollLeft, 0, "scrollLeft should be always 0");

element.scrollTop = 10;
element.scrollLeft = 10;
assert_equals(element.scrollTop, 0, "scrollTop should be always 0");
assert_equals(element.scrollLeft, 0, "scrollLeft should be always 0");

element.scroll(10, 10);
assert_equals(element.scrollTop, 0, "scrollTop should be always 0");
assert_equals(element.scrollLeft, 0, "scrollLeft should be always 0");

element.scrollTo(10, 10);
assert_equals(element.scrollTop, 0, "scrollTop should be always 0");
assert_equals(element.scrollLeft, 0, "scrollLeft should be always 0");

}, "Element get and set scrollTop, scrollLeft, scroll() and scrollTo() test");

done();
};
</script>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.