Skip to content

Add contentDocument support for HTMLIFrameElement. Fixes #3808. - #3953

Closed
neojski wants to merge 2 commits into
servo:masterfrom
neojski:implement-HTMLIFrameElement.contentDocument
Closed

neojski wants to merge 2 commits into
servo:masterfrom
neojski:implement-HTMLIFrameElement.contentDocument

Conversation

@neojski

@neojski neojski commented Nov 10, 2014

Copy link
Copy Markdown
Contributor

Because of #2122 I cannot write test for this right now because it will be failing randomly due to that iframe issue. However, if it doesn't fail due to that issue a test like this:

<html>
  <head>
    <meta charset="utf8" />
    <script src="harness.js"></script>
    <title>Iframe contentDocument test.</title>
  </head>
  <body>
    <iframe src="test_iframe_contentDocument_inner.html" id="iframe"></iframe>
    <script>
      waitForExplicitFinish();

      var timeout = 100;
      var iframe = document.getElementById('iframe');
      function test_contentWindow() {
        if (!iframe.contentWindow) {
          // Iframe not loaded yet, try again.
          // No load event for iframe, insert bug number here.
          setTimeout(test_contentWindow, timeout);
          return;
        }
        is(iframe.contentDocument.getElementById('test').textContent, 'value');
        finish();
      }
      test_contentWindow();
    </script>
  </body>
</html>

where inner is simply:

<html><body><div id="test">value</div></body></html>

passes.

I have added SameOrigin method to the UrlHelper. I wanted to reuse it in constellation.rs same_script check but I it didn't want to compile saying

error: unresolved import `dom::urlhelper::UrlHelper`. Maybe a missing `extern crate dom`?

So I didn't include it in this PR for now.

There is more discussion about the cross origin iframes in another issue. In this PR I just added same origin check.

@hoppipolla-critic-bot

Copy link
Copy Markdown

Critic review: https://critic.hoppipolla.co.uk/r/3144

This is an external review system which you may optionally use for the code review of your pull request.

In order to help critic track your changes, please do not make in-place history rewrites (e.g. via git rebase -i or git commit --amend) when updating this pull request.

@neojski
neojski force-pushed the implement-HTMLIFrameElement.contentDocument branch 2 times, most recently from 8bd59d7 to 1d85cd5 Compare November 13, 2014 23:16
@neojski

neojski commented Nov 13, 2014

Copy link
Copy Markdown
Contributor Author

Rebased. After recent iframe changes (although I didn't check whether it's really #3951 that fixed it but sounds possible) the test seem to work. What do you think @jdm ?

@jdm

jdm commented Nov 14, 2014

Copy link
Copy Markdown
Member

I would be exceedingly surprised if the test suddenly started to work. The fundamental problem identified in #2122 should still be present.

@jdm

jdm commented Nov 14, 2014

Copy link
Copy Markdown
Member

Worth a try, anyways!

bors-servo pushed a commit that referenced this pull request Nov 14, 2014
…ntDocument, r=jdm

Because of #2122 I cannot write test for this right now because it will be failing randomly due to that iframe issue. However, if it doesn't fail due to that issue a test like this:

```html
<html>
  <head>
    <meta charset="utf8" />
    <script src="harness.js"></script>
    <title>Iframe contentDocument test.</title>
  </head>
  <body>
    <iframe src="test_iframe_contentDocument_inner.html" id="iframe"></iframe>
    <script>
      waitForExplicitFinish();

      var timeout = 100;
      var iframe = document.getElementById('iframe');
      function test_contentWindow() {
        if (!iframe.contentWindow) {
          // Iframe not loaded yet, try again.
          // No load event for iframe, insert bug number here.
          setTimeout(test_contentWindow, timeout);
          return;
        }
        is(iframe.contentDocument.getElementById('test').textContent, 'value');
        finish();
      }
      test_contentWindow();
    </script>
  </body>
</html>
```
where inner is simply:
```html
<html><body><div id="test">value</div></body></html>
```
passes.

I have added `SameOrigin` method to the `UrlHelper`. I wanted to reuse it in [`constellation.rs` same_script check](https://github.com/servo/servo/blob/f0184a2d011e12845258a242d2d2f6b8b504a28d/components/compositing/constellation.rs#L625) but I it didn't want to compile saying

```
error: unresolved import `dom::urlhelper::UrlHelper`. Maybe a missing `extern crate dom`?
```

So I didn't include it in this PR for now.

There is more discussion about the cross origin iframes in [another issue](#3939). In this PR I just added same origin check.
@neojski
neojski force-pushed the implement-HTMLIFrameElement.contentDocument branch from 8d168f3 to fb8a45c Compare November 14, 2014 06:47
@neojski

neojski commented Nov 14, 2014

Copy link
Copy Markdown
Contributor Author

@jdm, there were some failures, can we try again?

bors-servo pushed a commit that referenced this pull request Nov 14, 2014
…ntDocument, r=jdm

Because of #2122 I cannot write test for this right now because it will be failing randomly due to that iframe issue. However, if it doesn't fail due to that issue a test like this:

```html
<html>
  <head>
    <meta charset="utf8" />
    <script src="harness.js"></script>
    <title>Iframe contentDocument test.</title>
  </head>
  <body>
    <iframe src="test_iframe_contentDocument_inner.html" id="iframe"></iframe>
    <script>
      waitForExplicitFinish();

      var timeout = 100;
      var iframe = document.getElementById('iframe');
      function test_contentWindow() {
        if (!iframe.contentWindow) {
          // Iframe not loaded yet, try again.
          // No load event for iframe, insert bug number here.
          setTimeout(test_contentWindow, timeout);
          return;
        }
        is(iframe.contentDocument.getElementById('test').textContent, 'value');
        finish();
      }
      test_contentWindow();
    </script>
  </body>
</html>
```
where inner is simply:
```html
<html><body><div id="test">value</div></body></html>
```
passes.

I have added `SameOrigin` method to the `UrlHelper`. I wanted to reuse it in [`constellation.rs` same_script check](https://github.com/servo/servo/blob/f0184a2d011e12845258a242d2d2f6b8b504a28d/components/compositing/constellation.rs#L625) but I it didn't want to compile saying

```
error: unresolved import `dom::urlhelper::UrlHelper`. Maybe a missing `extern crate dom`?
```

So I didn't include it in this PR for now.

There is more discussion about the cross origin iframes in [another issue](#3939). In this PR I just added same origin check.
@bors-servo bors-servo closed this Nov 14, 2014
@neojski

neojski commented Nov 14, 2014

Copy link
Copy Markdown
Contributor Author

I'm pretty sure we did sth wrong here because I wasn't asked to squash before it got merged and so this silly change has two commits. I'm sorry about that.

@Manishearth

Copy link
Copy Markdown
Member

I just re-r+d since Josh had already done so, after quickly cross checking.

Yeah, you could have squashed; but it's not necessary :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants