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

For Object and Embed tags, Dart needs to hand all attributes and methods to the element unmodified. #533

Closed
DartBot opened this issue Nov 19, 2011 · 20 comments
Labels
type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Nov 19, 2011

This issue was originally filed by jeffbailey@google.com


What steps will reproduce the problem?

  nethackEmbed = new Element.tag('embed');
  nethackEmbed.on['message'].add(handleMessage);

allows me to correctly receive messages for a NaCl-compiled C binary. However, the postMessage method isn't available and causes a run-time error:

  nethackEmbed.postMessage('bob');

Uncaught NoSuchMethodException - receiver: '[object Object]' function name: 'postMessage' arguments: [bob]]
$thrownethack.js:96
Object.noSuchMethodnethack.js:138
$varMethod.Objectnethack.js:234
$varMethod.Object.(anonymous function)nethack.js:6
handleMessagenethack.js:3467
wrappednethack.js:3076
wrap$1nethack.js:655
isolate$Isolate.runnethack.js:555
wrap$1nethack.js:654
(anonymous function)

What is the expected output? What do you see instead?

A message should be sent through the the embedded NaCl object.

What version of the product are you using? On what operating system?

URL: http://dart.googlecode.com/svn/trunk/dart/client/html
Repository Root: http://dart.googlecode.com/svn
Repository UUID: 260f80e4-7a28-3924-810f-c04153c831b5
Revision: 1684
Node Kind: directory
Schedule: normal
Last Changed Author: dgrove@google.com
Last Changed Rev: 1334
Last Changed Date: 2011-11-08 15:01:24 -0800 (Tue, 08 Nov 2011)

with one custom patch:

Index: frog/lib/json.js
===================================================================

--- frog/lib/json.js (revision 1684)
+++ frog/lib/json.js (working copy)
@@ -23,6 +23,7 @­@
   if (obj != null && typeof obj == 'object' && !(obj instanceof Array)) {
     return $fixupJsObjectToDartMap(obj);
   }

  • return obj;
     }
     
     // Converts the parsed JavaScript Object into a Dart Map.

This is compiled with Frog, on Ubuntu.

Please provide any additional information below.

@DartBot
Copy link
Author

DartBot commented Nov 21, 2011

This comment was originally written by jeffbailey@google.com

@DartBot
Copy link
Author

DartBot commented Nov 21, 2011

This comment was originally written by bradnelson@google.com


So on further investigation, it appears that what's happening is that frog/dart is entertaining the possibility that postMessage will be allowed on the nacl embed tag because it 'might' be an instance of the html5 postMessage method on window. For instance if jeff changes postMessage to foo, then it gets a compile time error.

Questions:

  1. I was under the impression that embed/objects could have arbitrary members/properties for example an npapi plugin has the ability to respond to interrogation has to what it supports. Does dart have some accommodation for this?
  2. Nacl / ppapi folk, is nacl grafted into chrome in some peculiar way? I assume that use of postmessage was just a attempt at homogeny with html5 similar mechanism. Or is it actually masquerading as something that might confuse dart's runtime?

@DartBot
Copy link
Author

DartBot commented Nov 21, 2011

This comment was originally written by dmichael@google.com


Attempts to answer:

  1. That's correct; an NPAPI plugin can expose any properties (incl. functions) it pleases, and it's not possible to enumerate them statically. (NaCl apps aren't able to do this, but other plugins e.g. Flash do this even with PPAPI)
  2. The current NaCl integration is just a trusted PPAPI plugin. Even for trusted PPAPI, 'postMessage' is exposed to JavaScript pretty much the same way as a plugin would do (using NPAPI functions in WebBindings). It only 'looks' like normal postMessage. It might be possible to get the Embed element to implement the MessagePort interface, but it would take a change to the spec or at least convincing WebKit maintainers that it's a good idea. I'm not really even convinced myself.

@DartBot
Copy link
Author

DartBot commented Nov 21, 2011

This comment was originally written by jeffbailey@google.com


Thanks. I ran into Ian Hickson at lunch and he pretty much told me the same thing.

So it sounds like in the case of either and embed or an object tag, Dart needs to just wrap the call in a try block and hand things over verbatim.

Retitling this bug to reflect that.


Changed the title to: "For Object and Embed tags, Dart needs to hand all attributes and methods to the element unmodified.".

@vsmenon
Copy link
Member

vsmenon commented Nov 21, 2011

As others have alluded, there are two issues here:

(1) Can/should plugins expose functionality to Dart?
I do not think we provide APIs for this today.

(2) If so, what should it look like in Dart?
It might not look like JavaScript. HTMLEmbedElement doesn't have a statically defined postMessage, so we do not declare one in Dart. Unlike JS, you cannot add your own methods or fields to an object after the fact. E.g., it might look more like:

nethackEmbed.invoke('postMessage', ['bob']);

@bradnelson: You're right about frog and postMessage. Frog is doing some simple compile analysis. It cannot (currently) prove that nethackEmbed doesn't have a postMessage method at compile time, but it can prove that it does not have a foo.

@DartBot
Copy link
Author

DartBot commented Nov 22, 2011

This comment was originally written by jeffbailey@google.com


Are there docs on how client/dom and client/html are generated and how to tell which ones Frog uses? I'm trying to piece together a patch to support .invoke, and I'm editing various generated files at the moment.

@vsmenon
Copy link
Member

vsmenon commented Nov 22, 2011

We're working on getting the docs out. In the meantime, client/dom/frog/frog_dom.dart and client/html/release/html.dart are the libraries pulled in by the frog compiler.

@DartBot
Copy link
Author

DartBot commented Nov 22, 2011

This comment was originally written by drfibonacci@google.com


Removed Type-Defect label.
Added Type-Enhancement, Area-Frog, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Nov 22, 2011

This comment was originally written by jeffbailey@google.com


I'm not sure about classifying this as an enhancement rather than a defect. I have a DOM node that I can't interact with and there's no work around. Seems like a bug to me.

@DartBot
Copy link
Author

DartBot commented Dec 8, 2011

This comment was originally written by jeffbailey@google.com


Assigning per jacobr. Jacob notes that this should be implemented using "No Such Method" and some of the changes to the Dart/JS Native Interface.


Set owner to @jmesserly.

@jmesserly
Copy link

Set owner to @rakudrama.

@anders-sandholm
Copy link
Contributor

Removed Area-Frog label.
Added Area-Dart2JS, FromAreaFrog labels.

@kasperl
Copy link

kasperl commented Jun 12, 2012

Is this a DOM issue, Stephen?


Removed Area-Dart2JS, FromAreaFrog labels.
Added Area-DOM label.

@vsmenon
Copy link
Member

vsmenon commented Jun 22, 2012

I don't think anyone is actively depending on this right now. Let us know if it's a blocker.


Added this to the Later milestone.

@DartBot
Copy link
Author

DartBot commented Jul 11, 2012

This comment was originally written by jeffbailey@google.com


I was depending on this but am not any longer (I've dropped Dart because of this and other issues. It's too much work to keep up with postprocessing the output)

@iposva-google
Copy link
Contributor

Removed Area-DOM label.
Added Area-HTML label.

@vsmenon
Copy link
Member

vsmenon commented Aug 17, 2012

Removed the owner.

@DartBot
Copy link
Author

DartBot commented Aug 31, 2012

This comment was originally written by joh...@johnmccutchan.com


Hi,

I need to be able to communicate from Dart to a NaCl plugin and I'm blocking on this. Who is working on this?

Thanks,
John

@sethladd
Copy link
Contributor

John has a killer bullet physics demo that we'd love to port to Dart + NaCL. Hoping we can move this to "sooner" rather than "later". Thanks!


cc @blois.

@sethladd
Copy link
Contributor

sethladd commented Jun 4, 2015

Not planned.

copybara-service bot pushed a commit that referenced this issue Jan 26, 2023
Revisions updated by `dart tools/rev_sdk_deps.dart`.

args (https://github.com/dart-lang/args/compare/04c9346..a23ea85):
  a23ea85  2023-01-25  Devon Carew  update the publishing script (#232)

dartdoc (https://github.com/dart-lang/dartdoc/compare/ed56883..99df16a):
  99df16a0  2023-01-24  Parker Lougheed  Use a sun for light theme toggle instead of moon (#3309)
  758e1851  2023-01-24  Parker Lougheed  Switch dart:js and some dart:js_util usages to use static interop (#3299)
  9735d895  2023-01-24  dependabot[bot]  Bump github/codeql-action from 2.1.38 to 2.1.39 (#3306)
  f6cd8eb9  2023-01-23  Sam Rawlins  Fix various bits in testing code to comply with new warnings (#3307)

http (https://github.com/dart-lang/http/compare/57c53b0..092bb2d):
  092bb2d  2023-01-25  Brian Quinlan  Create a `package:cronet_http/cronet_http.dart` import (#859)
  a62f5b3  2023-01-24  Brian Quinlan  Create a single top-level lib file. (#858)

intl (https://github.com/dart-lang/intl/compare/3fcc810..946c34c):
  946c34c  2023-01-25  Copybara-Service  Merge pull request #533 from dart-lang:updateVersion
  19b6785  2023-01-20  Moritz  Append `-dev` to current version

sse (https://github.com/dart-lang/sse/compare/be426a2..4e63b08):
  4e63b08  2023-01-25  Kevin Moore  Fix deprecated import to webdriver library (#76)

webdev (https://github.com/dart-lang/webdev/compare/f978b90..a347fa0):
  a347fa0  2023-01-25  Anna Gringauze  Update vm_service to version 10.0.0 (#1917)
  4dd29a5  2023-01-24  Anna Gringauze  Allow dart SDK <4.0.0 (#1913)
  b3db2c9  2023-01-24  Anna Gringauze  Prepare for dart 3.0 alpha changes: Handle SDK layout update (#1907)

Change-Id: I84d827db044f5b0af49b0454fd1d69b0d2ddf692
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279901
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Devon Carew <devoncarew@google.com>
copybara-service bot pushed a commit that referenced this issue Apr 24, 2023
…n, sse, stream_channel, test, tools, usage, webdev

Revisions updated by `dart tools/rev_sdk_deps.dart`.

async (https://github.com/dart-lang/async/compare/0127813..ce650b0):
  ce650b0  2023-04-19  Nate Bosch  Regression test for error rejecting transaction (#230)

characters (https://github.com/dart-lang/characters/compare/ba8d557..b306414):
  b306414  2023-04-19  Lasse R.H. Nielsen  Add tools to update and generate tables and tests. (#72)

convert (https://github.com/dart-lang/convert/compare/8812e40..855aeac):
  855aeac  2023-04-10  Kevin Moore  Require Dart 2.19, fix override param name, update lints (#81)

crypto (https://github.com/dart-lang/crypto/compare/1cb1528..77491f5):
  77491f5  2023-04-19  Lasse R.H. Nielsen  Make `DigestSink` implement `Sink` (#146)

dartdoc (https://github.com/dart-lang/dartdoc/compare/a0755f5..8e8b36e):
  8e8b36e3  2023-04-19  Janice Collins  Fix up documentation on comment reference parser to align with wiki (#2851)
  b9178fce  2023-04-19  dependabot[bot]  Bump github/codeql-action from 2.2.11 to 2.2.12 (#3390)
  37b981c4  2023-04-19  dependabot[bot]  Bump actions/checkout from 3.5.0 to 3.5.2 (#3389)
  dadef24a  2023-04-10  dependabot[bot]  Bump github/codeql-action from 2.2.9 to 2.2.11 (#3386)
  dda699a7  2023-04-10  Sam Rawlins  Prepare mixin-like classes for Dart 3.0.0 (#3385)

intl (https://github.com/dart-lang/intl/compare/a958db0..5d65e38):
  5d65e38  2023-04-19  Moritz  Update README.md
  9972a89  2023-04-19  Moritz  Update README.md
  5c14faa  2023-04-18  Copybara-Service  Merge pull request #584 from dart-lang:fixDateFormattingUrl
  4ea644e  2023-04-17  Moritz  Merge branch 'master' into fixDateFormattingUrl
  b0d5687  2023-04-17  dependabot[bot]  Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (#574)
  92149be  2023-04-17  Moritz  Merge branch 'master' into fixDateFormattingUrl
  5203d6e  2023-04-17  Googler  Internal change
  bab667f  2023-04-17  Moritz  Typo
  b0896b1  2023-04-17  Moritz  Fix bug
  43507e1  2023-04-14  Googler  Internal change
  d8844a0  2023-04-14  dependabot[bot]  Bump actions/checkout from 3.3.0 to 3.5.2 (#579)
  99ed16f  2023-04-13  Copybara-Service  Merge pull request #572 from dart-lang:adaptBrowserTest
  34e824c  2023-03-30  Moritz  Adapt test to browser CLDR update

markdown (https://github.com/dart-lang/markdown/compare/d437c85..5f98aea):
  5f98aea  2023-04-20  Jonas Finnemann Jensen  Throw, if `BlockSyntax.parseLines` loops indefinitely (#533)
  86ebc2c  2023-04-19  Zhiguang Chen  Fix `linkReferenceDefinitionPattern` (#532)

sse (https://github.com/dart-lang/sse/compare/11e83a0..f947c3d):
  f947c3d  2023-04-10  Kevin Moore  Require Dart 2.19, bump lints (#82)

stream_channel (https://github.com/dart-lang/stream_channel/compare/74646ea..71d4690):
  71d4690  2023-04-11  Tobe Osakwe  Add example/example.dart (#52)

test (https://github.com/dart-lang/test/compare/7832931..7fab079):
  7fab0792  2023-04-19  Oleh Prypin  Dart 3 compatibility: change `extends Iterator` to `implements Iterator` (#1997)
  8f7682a5  2023-04-18  Nate Bosch  Remove deprecation of test_api top level libraries (#1994)
  7151486c  2023-04-14  Simon Binder  Add support for Microsoft Edge (#1992)
  c1d686aa  2023-04-12  Parker Lougheed  Fix "Improvements" link in `package:checks` migration guide (#1991)

tools (https://github.com/dart-lang/tools/compare/545d7e1..5c9f45c):
  5c9f45c  2023-04-20  Elias Yishak  Move `dateStamp` getter to `utils.dart` (#83)

usage (https://github.com/dart-lang/usage/compare/0698711..f97752f):
  f97752f  2023-04-10  Devon Carew  update readme for deprecation (#192)

webdev (https://github.com/dart-lang/webdev/compare/7546291..8b42c95):
  8b42c950  2023-04-21  Anna Gringauze  Cleanup record types display (#2070)
  1cfb3bd6  2023-04-20  Elliott Brooks  Update CONTRIBUTING docs (#2097)
  941eda5b  2023-04-19  Elliott Brooks  Add a test to make sure proper release procedure is followed for `dwds` and `webdev` (#2095)
  2eb7c3ee  2023-04-17  Elliott Brooks  Add Github workflow for Dart Code Metrics (#2092)
  79a9bc9b  2023-04-17  Elliott Brooks  Fix DCM analyzer warnings (#2094)
  2a625039  2023-04-14  Elliott Brooks  Add `vm_service` git package dependency override (#2078)
  1fa19603  2023-04-12  Elliott Brooks  Add CI check to remind contributor to update CHANGELOG (#2090)
  c7bb19e1  2023-04-12  Elliott Brooks  Prevent PRs labeled `do-not-submit` from being merged (#2088)
  3781ef9b  2023-04-10  Elliott Brooks  Run mono_repo generate with version 6.5.3 (#2084)
  843890c6  2023-04-10  Anna Gringauze  Refactor record shape processing out of calculating record bound fields (#2074)

Change-Id: I4ce65f9f79d5086c33c575e57eff300216392510
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297800
Auto-Submit: Devon Carew <devoncarew@google.com>
Reviewed-by: Moritz Sümmermann <mosum@google.com>
Commit-Queue: Moritz Sümmermann <mosum@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

8 participants