-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into fix/bridge_memory_leaks
- Loading branch information
Showing
16 changed files
with
179 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (C) 2021 Alibaba Inc. All rights reserved. | ||
* Author: Kraken Team. | ||
*/ | ||
|
||
#include <gtest/gtest.h> | ||
#include "bridge_qjs.h" | ||
#include "host_object.h" | ||
#include "js_context.h" | ||
|
||
namespace kraken::binding::qjs { | ||
|
||
TEST(ModuleManager, shouldThrowErrorWhenBadJSON) { | ||
bool static errorCalled = false; | ||
auto* bridge = new kraken::JSBridge(0, [](int32_t contextId, const char* errmsg) { | ||
EXPECT_STREQ(errmsg, | ||
"TypeError: circular reference\n" | ||
" at __kraken_invoke_module__ (native)\n" | ||
" at <anonymous> (internal://:616)\n" | ||
" at Promise (native)\n" | ||
" at invokeMethod (internal://:617)\n" | ||
" at <eval> (vm://:12)\n"); | ||
errorCalled = true; | ||
}); | ||
kraken::JSBridge::consoleMessageHandler = [](void* ctx, const std::string& message, int logLevel) {}; | ||
|
||
auto& context = bridge->getContext(); | ||
|
||
std::string code = std::string(R"( | ||
let object = { | ||
key: { | ||
v: { | ||
a: { | ||
other: null | ||
} | ||
} | ||
} | ||
}; | ||
object.other = object; | ||
kraken.methodChannel.invokeMethod('abc', 'fn', object); | ||
)"); | ||
context->evaluateJavaScript(code.c_str(), code.size(), "vm://", 0); | ||
delete bridge; | ||
EXPECT_EQ(errorCalled, true); | ||
} | ||
|
||
} // namespace kraken::binding::qjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.