SeleniumHQ / selenium-google-code-issue-archive

Archive, please see main selenium repo
https://github.com/seleniumhq/selenium
345 stars 195 forks source link

promise.controlFlow() hangs when it returns an object with method "then" #7537

Closed lukeis closed 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 7537

promise.controlFlow() will hang when it returns an object with method "then." I think
it might be assuming the return object is of type webdriver.promise when it's not?

What steps will reproduce the problem?

describe('promise test', function() {

  ClassWithoutThen = function() {};
  it('class without then would work', function() {
    protractor.promise.controlFlow().execute(function() {
      return new ClassWithoutThen();
    }).then(function(res) {
      console.log("ClassWithoutThen works:", res);
    });
  })

  ClassWithThen = function() {};
  ClassWithThen.prototype.then = function() {};
  it('class with then would not work', function() {
    protractor.promise.controlFlow().execute(function() {
      return new ClassWithThen();
    }).then(function(res) {
      console.log("ClassWithThen works:", res);
    });
  })
});

Reported by hankduan@google.com on 2014-06-24 17:57:47

lukeis commented 8 years ago
Posting the result of the test run probably helps...
Anyway, the first test will work, while the second won't:

$ node lib/cli.js spec/hankConf.js Using the selenium server at http://localhost:4444/wd/hub ClassWithoutThen works: {} .F

Failures:

1) promise test class with then would not work Message: timeout: timed out after 30000 msec waiting for spec to complete Stacktrace: undefined

Finished in 32.687 seconds 2 tests, 1 assertion, 1 failure


Reported by `hankduan@google.com` on 2014-06-24 18:01:34
lukeis commented 8 years ago
It is recognizing the return value is promise-like and is waiting for it to be fulfilled.
This is 2.3.3.3 in the Promise/A+ spec:

http://promises-aplus.github.io/promises-spec/#point-56

Note: webdriver.promise isn't fully compliant with Promise/A+ yet, but most of the
remaining issues should be fixed with the 2.43 or 2.44 release.

Reported by jmleyba on 2014-06-24 18:08:18

lukeis commented 8 years ago

Reported by luke.semerau on 2015-09-17 18:22:40