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

I don't understand how the new mozbrowser API privilege works #11498

Closed
paulrouget opened this issue May 30, 2016 · 2 comments
Closed

I don't understand how the new mozbrowser API privilege works #11498

paulrouget opened this issue May 30, 2016 · 2 comments
Assignees

Comments

@paulrouget
Copy link
Contributor

@paulrouget paulrouget commented May 30, 2016

Maybe I missed something in the recent changes in the mozbrowser API, and codegen (#11308 and #11465), but:

The interface BrowserElementPrivileged describes special methods that should be only available if:

  1. the <iframe> is in the top level document,
  2. the <iframe> has a mozbrowser attribute
  3. the preference dom.enabled.mozbrowser is set to true

In HTMLIFrameElement.webidl it says: HTMLIFrameElement implements BrowserElement; without any condition.

I see [Func="Window::global_is_mozbrowser"] for the mozbrowser attribute, but not for all the other methods.

So if I'm not mistaken, that means that all the mozbrowser methods will be visible from any iframe, no matter what (even if the 3 conditions are not met) and only throw if 2 is false?

Also - HTMLIFrameElement.mozbrowser is only available if Window::global_is_mozbrowser, but that doesn't prevent me to do iframe.setAttribute("mozbrowser", true), does it?

I'm under the impression that:

  • the mozbrowser API is visible no matter what
  • the dom.mozbrowser preference does nothing
  • setting the mozbrowser attribute is enough to get the privileges
  • mozbrowser API is available in non top level pipelines
@paulrouget
Copy link
Contributor Author

@paulrouget paulrouget commented May 30, 2016

Here is a test (load a.html in servo):

<!-- a.html -->
<iframe mozbrowser="true" src="b.html"></iframe>
<script>
  var iframe = document.querySelector("iframe");
  iframe.addEventListener("mozbrowserloadend", _ => {
    console.log("a.html: mozbrowser event");
  });
  setTimeout(() => {
    console.log("a.html: " + iframe.goForward);
    try {
      iframe.goForward();
      console.log("a.html goForward() succeeded");
    } catch(e) {
      console.log("a.html goForward() failed: " + e);
    }
  }, 2000);
</script>
<!-- b.html -->
<iframe mozbrowser="true" src="data:,c"></iframe>
<script>
  var iframe = document.querySelector("iframe");
  iframe.addEventListener("mozbrowserloadend", _ => {
    console.log("b.html: mozbrowser event");
  });
  setTimeout(() => {
    console.log("b.html: " + iframe.goForward);
    try {
      iframe.goForward();
      console.log("b.html goForward() succeeded");
    } catch(e) {
      console.log("b.html goForward() failed: " + e);
    }
  }, 1000);
</script>

Without the pref, I see:

b.html: function goForward() {
    [native code]
}
b.html goForward() succeeded
a.html: function goForward() {
    [native code]
}
a.html goForward() succeeded

We should see:

b.html: undefined
b.html goForward() failed
a.html: undefined
a.html goForward() failed

With the pref I see:

b.html: mozbrowser event
a.html: mozbrowser event
b.html: function goForward() {
    [native code]
}
b.html goForward() succeeded
a.html: function goForward() {
    [native code]
}
a.html goForward() succeeded

We should see:

a.html: mozbrowser event
b.html: undefined
b.html goForward() failed
a.html: function goForward() {
    [native code]
}
a.html goForward() succeeded
@nox nox self-assigned this May 30, 2016
@nox
Copy link
Member

@nox nox commented May 30, 2016

So I should restore some of the checks in HTMLIFrameElement::Mozbrowser and add [Func] in BrowserElement.webidl. I had done that in my initial PR but I fumbled a rebase after addressing one of @jdm's comments I think.

bors-servo added a commit that referenced this issue May 30, 2016
Fix permissions of mozbrowser and BrowserElementPrivileged (fixes #11498)

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11508)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.