dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.08k stars 1.56k forks source link

HTTPRequest never executes in compiles JS #15888

Closed DartBot closed 9 years ago

DartBot commented 10 years ago

This issue was originally filed by ambusy...@gmail.com


What steps will reproduce the problem?

  1. install the One Hour Codelab Master, as indicates in the tutorial to learn DART (https://www.dartlang.org/codelabs/darrrt/)
  2. execute exercise 6 as compiled JS

What is the expected output? What do you see instead? I expect the screen to be equal to the Dartium version. It is not: de two buttons remain disabled. Which means that the statement PirateName.readyThePirates()     .then((_) {       //on success       inputField.disabled = false; //enable       genButton.disabled = false; //enable       setBadgeName(getBadgeNameFromStorage());     })     .catchError((arrr) {       print('Error initializing pirate names: $arrr');       badgeNameElement.text = 'Arrr! No names.';     }); never executes the .then branch

What version of the product are you using? On what operating system? Dart Editor version 1.0.0_r30798 (STABLE) Dart SDK version 1.0.0.10_r30798 Windows 7 SP1

Please provide any additional information below. exercises 1 to 5 run in Dartium and in compiled Js without difference

DartBot commented 10 years ago

This comment was originally written by am...@gmail.com


please change title, I oversaw that one. should read "HTTPRequest never executes in compiles JS"

lrhn commented 10 years ago

Added Area-Dart2JS, Triaged labels. Changed the title to: "HTTPRequest never executes in compiles JS".

floitschG commented 10 years ago

This looks like the http-request for the piratenames.json doesn't succeed.

I just tried the dart and js versions (from within the Dart editor), and both worked fine for me.

Could you please verify that the piratenames.json file is available to the dart2js-version too?


Added NeedsInfo label.

DartBot commented 10 years ago

This comment was originally written by ambus...@gmail.com


The file is available. I now realise that I omitted a very important clue: from within the Dart Editor both work. It is when I double-click the piratebadge.HTML file directly in Explorer, then the HTTPRequest never ends, and thus the .THEN is not executed. All 5 previous versions work: in Dartium, in Dart editor as compiled JS and executing the .HTML

floitschG commented 10 years ago

This is working as intended. The browser won't allow to load files, if the html is loaded through "file://". That's why it works from within the DartEditor.

The console prints (in both Dartium and Chromium): XMLHttpRequest cannot load file:///<path>/pirate/web/piratenames.json. Cross origin requests are only supported for HTTP.


Added AsDesigned label.

DartBot commented 10 years ago

This comment was originally written by ambusy...@gmail.com


I got the answer too, while walking (a long passage) with the dog: clicking the HTML runs without a server, so who is going to serve me? nobody of course. Dart editor creates the 127.0.0.1 server before executing the script