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

Add a test for the {Window,Document}.location getters. #1506

Closed
Ms2ger opened this issue Jan 7, 2015 · 10 comments
Closed

Add a test for the {Window,Document}.location getters. #1506

Ms2ger opened this issue Jan 7, 2015 · 10 comments

Comments

@Ms2ger
Copy link
Contributor

Ms2ger commented Jan 7, 2015

In particular, them being null if the document is not in a browsing context.

@ghost
Copy link

ghost commented Feb 16, 2015

I'd like to work on this but I'm not sure where to begin. Can someone please help me get started?

@Ms2ger
Copy link
Contributor Author

Ms2ger commented Feb 16, 2015

For example, you could test:

var doc = document.implementation.createHTMLDocument();
assert_equals(doc.location, null);

and

var iframe = document.createElement("iframe");
document.body.appendChild(iframe);
var win = iframe.contentWindow;
assert_not_equals(win.location, null);
assert_equals(win.location, win.document.location);
// ... and test its members
document.body.removeChild(iframe);
assert_equals(win.location, null);
assert_equals(win.document.location, null);

@ghost
Copy link

ghost commented Mar 18, 2015

I'm still trying to get my feet wet but I think I have done what's needed to fulfill the example provided above. However I'm not sure if I've put it in the right place and I need help researching if this is the extent of what's needed. Perhaps if you could help give me a push in the right direction here I can try to figure it out.

As an aside, I noticed that I'm getting a failure in /dom/nodes/DOMImplementation-createHTMLDocument.html without any changes. I'm not sure if this needs to get fixed separately:

createHTMLDocument(): metadata  assert_equals: expected (string) "UTF-8" but got (object) null

@http://web-platform.test:8000/dom/nodes/DOMImplementation-createHTMLDocument.html:72:3
Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1227:20
test@http://web-platform.test:8000/resources/testharness.js:428:9
@http://web-platform.test:8000/dom/nodes/DOMImplementation-createHTMLDocument.html:66:1

At any rate, here is what I've come up with so far for my tests:

diff --git a/dom/nodes/DOMImplementation-createHTMLDocument.html b/dom/nodes/DOMImplementation-createHTMLDocument.html
index 89dc383..e4afbc6 100644
--- a/dom/nodes/DOMImplementation-createHTMLDocument.html
+++ b/dom/nodes/DOMImplementation-createHTMLDocument.html
@@ -81,4 +81,22 @@ test(function() {
   a.href = "http://example.org/?\u00E4";
   assert_equals(a.href, "http://example.org/?%C3%A4");
 }, "createHTMLDocument(): URL parsing")
+
+// Test that document.location getter is null outside browser context
+test(function() {
+   var doc = document.implementation.createHTMLDocument();
+    assert_equals(doc.location, null);
+}, "createHTMLDocument(): doc.location getter")
+
+// Test that window.location getter is null outside browser context
+test(function() {
+   var iframe = document.createElement("iframe");
+    document.body.appendChild(iframe);
+    var win = iframe.contentWindow;
+    assert_not_equals(win.location, null);
+    assert_equals(win.location, win.document.location);
+    document.body.removeChild(iframe);
+    assert_equals(win.location, null);
+    assert_equals(win.document.location, null);
+}, "createHTMLDocument(): win.location getter")
 </script>

I ran this locally and the tests seem to pass, aside from the previous failure mentioned above.

@Ms2ger
Copy link
Contributor Author

Ms2ger commented Apr 12, 2015

Those look great, but the second test doesn't belong in that file.

@ghost
Copy link

ghost commented Apr 13, 2015

Those look great, but the second test doesn't belong in that file.

@Ms2ger What is the correct file for the second test?

@Ms2ger
Copy link
Contributor Author

Ms2ger commented Apr 14, 2015

A new file under html/browsers/history/the-location-interface/, I think

@ghost
Copy link

ghost commented Apr 15, 2015

@Ms2ger I'm not sure if I did this right as I'm still a newbie to github. Can you check to see if this pull request looks right? #1757

@ghost
Copy link

ghost commented Sep 8, 2015

I'm sorry but I'm going to have to drop this for now. I switched over to the gfx team last quarter and just don't have the time to continue working on this. My apologies but I'd rather be honest and drop this than let it linger indefinitely.

@Honry
Copy link
Contributor

Honry commented Aug 15, 2018

@Ms2ger, this was already fixed by #7574, right? Can we close it?

@Ms2ger
Copy link
Contributor Author

Ms2ger commented Aug 15, 2018

Looks like it.

@Ms2ger Ms2ger closed this as completed Aug 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants