diff --git a/common/lib/xmodule/xmodule/js/src/conditional/display.js b/common/lib/xmodule/xmodule/js/src/conditional/display.js index fe0d7284ac7ac40df3c11a3bf86cdc6a5569399e..7d08d159dfcf0f6faa265dc8b198b617318770ba 100644 --- a/common/lib/xmodule/xmodule/js/src/conditional/display.js +++ b/common/lib/xmodule/xmodule/js/src/conditional/display.js @@ -139,6 +139,7 @@ kind = resource.kind, placement = resource.placement, data = resource.data; + var loaded; if (mimetype === 'text/css') { if (kind === 'text') { // xss-lint: disable=javascript-jquery-append,javascript-concat-html @@ -152,7 +153,11 @@ // xss-lint: disable=javascript-jquery-append,javascript-concat-html $head.append('<script>' + data + '</script>'); } else if (kind === 'url') { - $script(data, data); + loaded = $.Deferred(); + $script(data, data, function() { + loaded.resolve() + }); + return loaded.promise(); } } else if (mimetype === 'text/html') { if (placement === 'head') { diff --git a/common/test/acceptance/pages/lms/conditional.py b/common/test/acceptance/pages/lms/conditional.py index 139c9b7486955cf0f19be343ee681fbccf31e339..f7ac87dd7b003e5be1fc677db2f1ea1cbdf6dbaf 100644 --- a/common/test/acceptance/pages/lms/conditional.py +++ b/common/test/acceptance/pages/lms/conditional.py @@ -2,6 +2,7 @@ Conditional Pages """ from bok_choy.page_object import PageObject +from bok_choy.promise import EmptyPromise, BrokenPromise POLL_ANSWER = 'Yes, of course' @@ -17,14 +18,34 @@ class ConditionalPage(PageObject): """ Returns True if the browser is currently on the right page. """ - return self.q(css='.conditional-wrapper').visible + # This is all a hack to work around the fact that there's no way to adjust the + # timeout parameters for self.q + def check_fn(): + return self.q(css='.conditional-wrapper').visible + try: + EmptyPromise( + check_fn, + "On conditional page", + ).fulfill() + return True + except BrokenPromise: + return False def is_content_visible(self): """ Returns True if the conditional's content has been revealed, False otherwise """ - return self.q(css='.hidden-contents').visible + def check_fn(): + return self.q(css='.hidden-contents').visible + try: + EmptyPromise( + check_fn, + "Conditional is visible", + ).fulfill() + return True + except BrokenPromise: + return False def fill_in_poll(self): """