// NOTE: this file needs to be split up rather than expanded. See ../location.sub.html for some // extracted tests. Tracked by https://github.com/web-platform-tests/wpt/issues/4934. /* * help: * https://html.spec.whatwg.org/multipage/#the-link-element * https://html.spec.whatwg.org/multipage/#styling * https://html.spec.whatwg.org/multipage/#prepare-a-script * https://html.spec.whatwg.org/multipage/#concept-media-load-algorithm * https://html.spec.whatwg.org/multipage/#track-url * https://html.spec.whatwg.org/multipage/#concept-form-submit * https://html.spec.whatwg.org/multipage/#set-the-frozen-base-url * https://dom.spec.whatwg.org/#dom-node-baseuri * https://html.spec.whatwg.org/multipage/#the-a-element * https://html.spec.whatwg.org/multipage/#dom-worker * https://html.spec.whatwg.org/multipage/#dom-sharedworker * https://html.spec.whatwg.org/multipage/#dom-eventsource * https://html.spec.whatwg.org/multipage/#dom-xmldocument-load * https://html.spec.whatwg.org/multipage/#dom-open * http://url.spec.whatwg.org/#dom-url-search * https://www.w3.org/Bugs/Public/show_bug.cgi?id=24148 * https://xhr.spec.whatwg.org/#the-open()-method * https://html.spec.whatwg.org/multipage/#set-up-a-worker-script-settings-object * https://html.spec.whatwg.org/multipage/#dom-workerglobalscope-importscripts * https://html.spec.whatwg.org/multipage/#parse-a-websocket-url's-components * https://html.spec.whatwg.org/multipage/#dom-websocket-url * https://www.w3.org/Bugs/Public/show_bug.cgi?id=23968 * http://dev.w3.org/csswg/cssom/#requirements-on-user-agents-implementing-the-xml-stylesheet-processing-instruction * http://url.spec.whatwg.org/#dom-url */ setup({explicit_done:true}); onload = function() { var encoding = '{{GET[encoding]}}'; var input_url = 'resources/resource.py?q=\u00E5&encoding=' + encoding + '&type='; ('html css js worker sharedworker worker_importScripts sharedworker_importScripts worker_worker worker_sharedworker sharedworker_worker '+ 'sharedworker_sharedworker eventstream png svg xmlstylesheet_css video webvtt').split(' ').forEach(function(str) { window['input_url_'+str] = input_url + str; }); var blank = 'resources/blank.py?encoding=' + encoding; var stash_put = 'resources/stash.py?q=\u00E5&action=put&id='; var stash_take = 'resources/stash.py?action=take&id='; var expected_obj = { 'utf-8':'%C3%A5', 'utf-16be':'%C3%A5', 'utf-16le':'%C3%A5', 'windows-1252':'%E5', 'windows-1251':'%26%23229%3B' }; var expected_current = expected_obj[encoding]; var expected_utf8 = expected_obj['utf-8']; function msg(expected, got) { return 'expected substring '+expected+' got '+got; } function poll_for_stash(test_obj, uuid, expected) { var start = new Date(); var poll = test_obj.step_func(function () { var xhr = new XMLHttpRequest(); xhr.open('GET', stash_take + uuid); xhr.onload = test_obj.step_func(function(e) { if (xhr.response == "") { if (new Date() - start > 10000) { // If we set the status to TIMEOUT here we avoid a race between the // page and the test timing out test_obj.force_timeout(); } test_obj.step_timeout(poll, 200); } else { assert_equals(xhr.response, expected); test_obj.done(); } }); xhr.send(); }) test_obj.step_timeout(poll, 200); } // loading html (or actually svg to support ) function test_load_nested_browsing_context(tag, attr, spec_url) { subsetTestByKey('nested-browsing', async_test, function() { var id = 'test_load_nested_browsing_context_'+tag; var elm = document.createElement(tag); elm.setAttribute(attr, input_url_svg); elm.name = id; document.body.appendChild(elm); this.add_cleanup(function() { document.body.removeChild(elm); }); elm.onload = this.step_func_done(function() { assert_equals(window[id].document.documentElement.textContent, expected_current); }); }, 'load nested browsing context <'+tag+' '+attr+'>'); } spec_url_load_nested_browsing_context = { frame:'https://html.spec.whatwg.org/multipage/#process-the-frame-attributes', iframe:'https://html.spec.whatwg.org/multipage/#process-the-iframe-attributes', object:'https://html.spec.whatwg.org/multipage/#the-object-element', embed:'https://html.spec.whatwg.org/multipage/#the-embed-element-setup-steps' }; 'frame src, iframe src, object data, embed src'.split(', ').forEach(function(str) { var arr = str.split(' '); test_load_nested_browsing_context(arr[0], arr[1], spec_url_load_nested_browsing_context[arr[0]]); }); // loading css with subsetTestByKey('loading', async_test, function() { var elm = document.createElement('link'); elm.href = input_url_css; elm.rel = 'stylesheet'; document.head.appendChild(elm); this.add_cleanup(function() { document.head.removeChild(elm); }); elm.onload = this.step_func_done(function() { var got = elm.sheet.href; assert_true(elm.sheet.href.indexOf(expected_current) > -1, 'sheet.href ' + msg(expected_current, got)); assert_equals(elm.sheet.cssRules[0].style.content, '"'+expected_current+'"', 'sheet.cssRules[0].style.content'); }); }, 'loading css '); // loading js subsetTestByKey('loading-css', async_test, function() { var elm = document.createElement('script'); elm.src = input_url_js + '&var=test_load_js_got'; document.head.appendChild(elm); // no cleanup elm.onload = this.step_func_done(function() { assert_equals(window.test_load_js_got, expected_current); }); }, 'loading js