Bug 1502802 - Implement PostMessageOptions for Window, r=smaug

This commit is contained in:
Andrea Marchesini 2018-10-29 16:26:30 +01:00
Родитель 4817d8d6c8
Коммит 70526c2e29
17 изменённых файлов: 32 добавлений и 64 удалений

Просмотреть файл

@ -4124,6 +4124,25 @@ nsGlobalWindowInner::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessa
aSubjectPrincipal, aRv);
}
void
nsGlobalWindowInner::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
const WindowPostMessageOptions& aOptions,
nsIPrincipal& aSubjectPrincipal,
ErrorResult& aRv)
{
JS::Rooted<JS::Value> transferArray(aCx, JS::UndefinedValue());
aRv = nsContentUtils::CreateJSValueFromSequenceOfObject(aCx,
aOptions.mTransfer,
&transferArray);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
PostMessageMoz(aCx, aMessage, aOptions.mTargetOrigin, transferArray,
aSubjectPrincipal, aRv);
}
void
nsGlobalWindowInner::Close(ErrorResult& aError)
{

Просмотреть файл

@ -133,6 +133,7 @@ class WakeLock;
#if defined(MOZ_WIDGET_ANDROID)
class WindowOrientationObserver;
#endif
struct WindowPostMessageOptions;
class Worklet;
namespace cache {
class CacheStorage;
@ -736,6 +737,10 @@ public:
const mozilla::dom::Sequence<JSObject*>& aTransfer,
nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& aError);
void PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
const mozilla::dom::WindowPostMessageOptions& aOptions,
nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& aError);
int32_t SetTimeout(JSContext* aCx, mozilla::dom::Function& aFunction,
int32_t aTimeout,
const mozilla::dom::Sequence<JS::Value>& aArguments,

Просмотреть файл

@ -362,13 +362,6 @@ var tests =
source: "idnKidNoWhitelist",
returnOrigin: "http://sub1.xn--exaple-kqf.test",
},
// 55
{
args: ["NOT-RECEIVED", undefined],
source: "sameDomain",
name: "SyntaxError",
code: DOMException.SYNTAX_ERR
},
];
function allTests(callback)

Просмотреть файл

@ -85,6 +85,8 @@ typedef OfflineResourceList ApplicationCache;
[Throws, CrossOriginCallable, NeedsSubjectPrincipal]
void postMessage(any message, DOMString targetOrigin, optional sequence<object> transfer = []);
[Throws, CrossOriginCallable, NeedsSubjectPrincipal]
void postMessage(any message, optional WindowPostMessageOptions options);
// also has obsolete members
};
@ -576,3 +578,7 @@ partial interface Window {
readonly attribute VisualViewport visualViewport;
};
dictionary WindowPostMessageOptions : PostMessageOptions {
USVString targetOrigin = "/";
};

Просмотреть файл

@ -1,8 +0,0 @@
[appcache-iframe.https.html]
expected: TIMEOUT
[iframe should be loaded from application caches for fallback.]
expected: NOTRUN
[iframe should be loaded from application caches.]
expected: TIMEOUT

Просмотреть файл

@ -347,12 +347,6 @@
[Window interface: window must inherit property "onunhandledrejection" with the proper type]
expected: FAIL
[Window interface: operation postMessage(any, USVString, [object Object\])]
expected: FAIL
[Window interface: operation postMessage(any, [object Object\], WindowPostMessageOptions)]
expected: FAIL
[html interfaces]
expected: FAIL

Просмотреть файл

@ -1,4 +0,0 @@
[host-specific-origin.tentative.html]
[resolving url with stuff in host-specific]
expected: FAIL

Просмотреть файл

@ -1,4 +0,0 @@
[message-channel-transferable.tentative.html]
[MessageChannel's ports as MessagePort objects]
expected: FAIL

Просмотреть файл

@ -1,4 +0,0 @@
[no-target-origin.tentative.html]
[no targetOrigin]
expected: FAIL

Просмотреть файл

@ -1,4 +0,0 @@
[null-transfer.tentative.html]
[null transfer]
expected: FAIL

Просмотреть файл

@ -1,4 +0,0 @@
[one-arg.tentative.html]
[just one argument]
expected: FAIL

Просмотреть файл

@ -1,4 +0,0 @@
[slash-origin.tentative.html]
[special value '/']
expected: FAIL

Просмотреть файл

@ -1,4 +0,0 @@
[undefined-transferable.tentative.html]
[undefined as transferable]
expected: FAIL

Просмотреть файл

@ -1,4 +0,0 @@
[unknown-parameter.tentative.html]
[unknown parameter]
expected: FAIL

Просмотреть файл

@ -1,4 +0,0 @@
[027.html]
[message channel as ports]
expected: FAIL

Просмотреть файл

@ -1,4 +0,0 @@
[second-argument-null.html]
[Using null in postMessage's second argument]
expected: FAIL

Просмотреть файл

@ -5,8 +5,7 @@
<div id="log"></div>
<script>
test(function() {
assert_throws(new TypeError(), function() {
postMessage('');
});
postMessage('');
this.done();
});
</script>